/** 
 *    author:  pankaj_m05
 *    created: 19.12.2020 23:17:06
**/
#include<bits/stdc++.h>
#define sz(x) (int(x.size()))

using namespace std;

struct fenwick {
	int n;
	vector< int > bit;
	
	fenwick(int n) {
		this -> n = n;
		bit.assign(n + 1, 0);    
	}
	
	fenwick(vector< int >& a) : fenwick(sz(a)) {
		for (int i = 1; i <= n; ++i) 
			update(i, a[i - 1]);    
	}
	
	void update(int idx, int k) {
		for (int i = idx; i <= n; i += i & -i) 
			bit[i] ^= k;
	}
  
	int sum(int idx) {
		int ans = 0;
		for (int i = idx; i; i -= i & -i)
			ans ^= bit[i];
		return ans;
  }
	
	int range(int l, int r) {
  	return sum(r) ^ sum(l - 1);
	}
};

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
  	cin >> a[i];
  }
  fenwick f(a);
  while (q--) {
  	int t;
  	cin >> t;
  	if (t == 1) {
  		int x, v;
  		cin >> x >> v;
  		f.update(x, v);
  	} else { 
  		int l, r;
  		cin >> l >> r;
  		cout << f.range(l, r) << '\n';
  	}
  }
  return 0;
}
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<list>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int sol(const string& S) {
	const string A = "atcoder";
	if (S > A)return 0;
	int len = S.size(), K = 0;
	for (int i = 0; i < len; i++) {
		if (S[i] != 'a') {
			K = i;
			break;
		}
		if (i == len - 1)return -1;
	}

	if (S[1] != 'a')return 1;
	if (S[K] > 't')return K - 1;
	else return K;
}

int main() {
	int T; cin >> T;
	for (int i = 0; i < T; i++) {
		string S; cin >> S;
		cout << sol(S) << endl;
	}
}
