#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx")
#pragma GCC target ("avx2,fma")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <atcoder/all>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define rank fewfewf
#define double long double

using namespace std;
using namespace __gnu_pbds;
//using namespace atcoder;


typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 705000;
const int K = 20;
const int mod = 1e9 + 7;
int x, y;
map<int,int> m;
int solve(int z){
    if (m.find(z) != m.end()) return m[z];
    m[z] = abs(z - x);
    for (int i = -1; i <= 1; i++){
        if ((z + i) % 2 == 0) m[z] = min(m[z], 1 + abs(i) + solve((z + i) / 2));
    }
    return m[z];
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("input.txt", "w", stdout);
    cin >> x >> y;
    cout << solve(y);
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

const int DEPTH = 19;
class SegTree {
public:
	int val[1 << (DEPTH + 1)];
	SegTree() {
		for (int i = 0; i < (1 << (DEPTH + 1)); i++) {
			val[i] = 0;
		}
	}
	void update(int pos, int x) {
		pos += (1 << DEPTH) - 1;
		val[pos] ^= x;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			val[pos] = val[2 * pos + 1] ^ val[2 * pos + 2];
		}
	}
	int query(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return 0;
		if (l <= a && b <= r) return val[id];
		int res1 = query(l, r, a, (a + b) / 2, id * 2 + 1);
		int res2 = query(l, r, (a + b) / 2, b, id * 2 + 2);
		return res1 ^ res2;
	}
};

SegTree seg;
int n, q;
int a[300000];
int t, x, y;

signed main() {
	int i;
	
	cin >> n >> q;
	rep(i, n) cin >> a[i];
	rep(i, n) seg.update(i, a[i]);
	rep(i, q) {
		cin >> t >> x >> y;
		x--;
		if (t == 1) { seg.update(x, y); }
		else { cout << seg.query(x, y) << endl; }
	}
	return 0;
}