#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

auto io_speed = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    return 0;
}();

ll pow_mod(ll a, ll e, ll mod) {
    ll res = 1;
    while(e) {
        if(e&1) res = res * a%mod;
        e>>=1;
        a=a*a%mod;
    }
    return res;
}

ll inv_mod(ll b, ll m) {
    ll a=m, x=0, y=1, r, q;
    while(b) {
        r = a%b;
        q = a/b;
        a = b;
        b = r;
        r = x;
        x = y;
        y = r-q*y;
    }
    x+=m;
    return x%m;
}
const ll INF = 1E18+10;
void solve() {
    int n, q;
    cin >> n >> q;
    vector<ll> arr(n);
    for(auto &x: arr) cin >> x;
    
    while(q--) {
        ll k;
        cin >> k;
        if(k < arr.front()) {
            cout << k << endl;
        } else if(arr.back()-n < k) {
            cout << k+n <<endl;
        } else {
            int l = 0, h = n-1;
            while(l < h) {
                int m = (l+h)>>1;
                if(arr[m]-(m+1) < k) {
                    l = m + 1;
                } else h = m;
            }
            if(arr[l]-(l+1) >= k) l--;
            cout << k + l + 1 << endl;
        }
    }
}

int main() {
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++) {
        // cout << "Case #"<<i<<": ";
        solve();
    }
}
#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define dbg3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;
#define nl() cout << "========================================" << endl;
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }
#define yn { puts("Yes"); } else{ puts("No"); } // 使い方: if (条件) yn; 

template<typename T> 
struct SegmentTree {
    private:
        T n;
        vector<T> node;

    public:
        SegmentTree(vector<T> v) {
            T nv = v.size();
            // セグメントツリーは完全二分木である必要がある。nv以上の最小の2のべき乗数を求める。
            n = 1; while (n < nv) n *= 2;

            // ノードの数は2n-1 (n + n/2 + n/4 + ... + 1 = 2n-1)
            node.resize(2 * n - 1, 0);
            rep(i, nv) node[n - 1 + i] = v[i];
            // ノードnの子のノードは2n+1と2n+2、ノードの親は(n-1)/2
            for (int i = n - 2; i >= 0; i--) node[i] = node[2 * i + 1] ^ node[2 * i + 2];
        }

        void update(T x, T val) {
            x += n - 1;
            node[x] ^= val;
            while (x > 0) {
                x = (x - 1) / 2;
                node[x] = node[2 * x + 1] ^ node[2 * x + 2];
            }
        }

        /**
         * 区間[a, b)の要素の最小値を求める
         * k: 自分が今いるノードのインデックス
         * [l, r): 対象区間
         */
        T get(T a, T b, T k = 0, T l = 0, T r = -1) {
            if (r < 0) r = n;
            if (r <= a || b <= l) return 0;
            if (a <= l && r <= b) return node[k];

            T vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
            T vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
            return vl ^ vr;
        }

        void show() {
            cout << "n: " << n << endl;
            rep(i, 2 * n - 1) {
                cout << "  i: " << i << ", node[i]: " << node[i] << endl;
            }
        }
};

int main() {
    int N, Q; cin >> N >> Q;
    vl A(N); rep(i, N) cin >> A[i];
    SegmentTree<ll> seg(A);
    rep(i, Q) {
        ll T, X, Y; cin >> T >> X >> Y;
        if (T == 1) {
            seg.update(X - 1, Y);
        } else {
            cout << seg.get(X - 1, Y) << endl;
        }
    }
}
