#include #include #include #include #include #include #include #include #define vv(a, b, c, d) vector >(a, vector(b, c)) #define vvi std::vector > #define vvl std::vector > #define MODs 1000000007; typedef long long int ll; using namespace std; //------------------------------------------------------------------- int M=1, INF=1000000007; std::vector idx(100001, -1); std::vector seg; void init(int N){ while(M0){ k = (k-1)/2; seg[k] = min(seg[k*2+1], seg[k*2+2]); } } ll query(int a, int b, int l, int r, int k){ if(r<=a || b<=l) return INF; if(a<=l && r<=b) return seg[k]; ll A = query(a, b, l, (l+r)/2, k*2+1); ll B = query(a, b, (l+r)/2, r, k*2+2); return min(A, B); } //------------------------------------------------------------------- int main(int argc, char const *argv[]) { int N, Q, a, b, c; std::cin >> N >> Q; init(N+1); for(int i=0;i> a; idx[a] = i+1; update(0, (M+1)/2, a, i); } for(int i=0;i> a >> b >> c; b--,c--; if(a==1){ int tmp = seg[b+(M+1)/2-1], tmpidx=idx[seg[b+(M+1)/2-1]]; int tmp2 = seg[c+(M+1)/2-1], tmpidx2=idx[seg[c+(M+1)/2-1]]; idx[tmp] = tmpidx2, idx[tmp2] = tmpidx; update(0, (M+1)/2, tmp2, b), update(0, (M+1)/2, tmp, c); }else { std::cout << idx[query(b, c+1, 0, (M+1)/2, 0)] << '\n'; } } return 0; }