#include using namespace std; typedef long long ll; typedef pair l_l; typedef pair i_i; template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const int INF = 1e9; struct SegmentTree { private: int n; vector node; public: SegmentTree() { int sz = 100050; n = 1; while(n < sz) n *= 2; node.resize(2*n-1, {INF,0}); for(int i=0; i=0; i--) node[i] = min(node[2*i+1], node[2*i+2]); } void update(int x, int val) { x += (n - 1); node[x].first = val; while(x > 0) { x = (x - 1) / 2; node[x] = min(node[2*x+1], node[2*x+2]); } } // hannkaikukann i_i getmin(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(r <= a || b <= l) return {INF,0}; if(a <= l && r <= b) return node[k]; i_i vl = getmin(a, b, 2*k+1, l, (l+r)/2); i_i vr = getmin(a, b, 2*k+2, (l+r)/2, r); return min(vl, vr); } }; int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); int N, Q; cin >> N >> Q; SegmentTree seg; for(int i = 1; i <= N; i++) { int a; cin >> a; seg.update(i, a); } while(Q--) { int ope, l, r; cin >> ope >> l >> r; if(ope == 1) { int v1 = seg.getmin(l, l+1).first; int v2 = seg.getmin(r, r+1).first; seg.update(l, v2); seg.update(r,v1); continue; } else { cout << seg.getmin(l, r + 1).second << endl; } } return 0; }