using System; using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math; using Pair = System.Collections.Generic.KeyValuePair; class Program { static void Main() { var NQ = ReadLine().Split().Select(int.Parse).ToArray(); var N = NQ[0]; var Q = NQ[1]; var a = ReadLine().Split().Select(int.Parse).Select((x, i) => new Pair(i + 1, x)).ToArray(); var s = new SegmentTree(a, Mindex, new Pair(0, int.MaxValue)); for (int i = 0; i < Q; i++) { var line = ReadLine().Split().Select(int.Parse).ToArray(); var q = line[0]; var l = line[1] - 1; var r = line[2] + (q == 1 ? -1 : 0); if (q == 1) { var k = s[l].Value; s[l] = new Pair(l + 1, s[r].Value); s[r] = new Pair(r + 1, k); } else { WriteLine(s.Query(l, r).Key); } } } static Pair Mindex(Pair l, Pair r) => l.Value < r.Value ? l : r; } public class SegmentTree { T[] buffer;//0-index int N; public int Length => N; T TI; Func F;//デリゲート遅そう  public SegmentTree(int length, Func f, T ti)//モノイドが直接渡せれば C#9.0ではいるか { N = length; buffer = new T[N * 2 - 1]; for (int i = 0; i < buffer.Length; i++) buffer[i] = ti; //! F = f; TI = ti; } public SegmentTree(T[] init, Func f, T ti) { N = init.Length; buffer = new T[N * 2 - 1]; Array.Copy(init, 0, buffer, N - 1, init.Length); for (int i = N - 2; i >= 0; i--) { buffer[i] = f(buffer[i * 2 + 1], buffer[i * 2 + 2]); } F = f; TI = ti; } public void Update(int k, T v)//k [0, N) { k += N - 1; buffer[k] = v; while (k > 0) { k = (k - 1) >> 1; buffer[k] = F(buffer[k * 2 + 1], buffer[k * 2 + 2]); } } public T this[int k] { set//setの式形式はC#7.0以降 { Update(k, value); } get { return buffer[k + N - 1]; } } public T Query(int l, int r)//[l, r) 0 <= l, r <= N // 0 <= r - l のとき空区間 { var lv = TI; var rv = TI; l += N - 1; r += N - 1; while (l < r) { if ((l & 1) == 0) { lv = F(lv, buffer[l]); } if ((r & 1) == 0) { rv = F(buffer[r - 1], rv); } l >>= 1; r = (r - 1) >> 1; } return F(lv, rv); } }