#include using namespace std; inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template inline string toString(T x) {ostringstream sout;sout< VI; typedef vector VVI; typedef vector VS; typedef pair P; typedef tuple tpl; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SORT(c) sort((c).begin(),(c).end()) #define REVERSE(c) reverse((c).begin(),(c).end()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i) #define RREP(i,n) RFOR(i,n,0) const double EPS = 1e-9; const double PI = acos(-1.0); const int INT_INF = 2147483647; const long long LL_INF = 1LL<<60; const long long MOD = 1000000007; #define CLR(a) memset((a), 0 ,sizeof(a)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 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; } template struct SegmentTree { typedef function F; typedef function G; int n; F f; G g; T e; vector val; SegmentTree(vector a, F f_, G g_, T e_): f(f_), g(g_), e(e_){ int sz = a.size(); n = 1; while (n < sz) n <<= 1; val.resize(2 * n - 1, e); for (int i = 0; i < sz; i++) val[i + n - 1] = a[i]; for (int i = n - 2; i >= 0; i--) val[i] = f(val[i * 2 + 1], val[i * 2 + 2]); } SegmentTree() {} void update(int pos, T v) { int k = pos + n - 1; val[k] = g(val[k], v); while (k > 0) { k = (k - 1) / 2; val[k] = f(val[k * 2 + 1], val[k * 2 + 2]); } } T get(int pos) { int k = pos + n - 1; return val[k]; } T query(int a, int b, int k = 0, int l = 0, int r = -1) { if (r < 0) r = n; if (r <= a || b <= l) return e; if (a <= l && r <= b) return val[k]; T lv = query(a, b, k * 2 + 1, l, (l + r) / 2); T rv = query(a, b, k * 2 + 2, (l + r) / 2, r); return f(lv, rv); } }; int main(void){ int N,Q; cin >> N >> Q; vector

a(N); REP(i,N){cin >> a[i].first; a[i].second = i+1;} auto f = [](P a, P b){return a < b ? a : b;}; auto g = [](P a, P b){return P(b.first, a.second);}; SegmentTree

st(a, f, g, P(N+1,0)); REP(i,Q){ int c,l,r; cin >> c >> l >> r; l--; r--; if(c == 1){ P al = st.get(l), ar = st.get(r); st.update(l, P(ar.first, l+1)); st.update(r, P(al.first, r+1)); } else{ P ans = st.query(l,r+1); cout << ans.second << endl; } } return 0; }