#include<bits/stdc++.h>
#define for0(n) for(lli i=0;i<n;i++)
#define in(x) lli x; cin>>x
using namespace std;
typedef long long int lli;
void buildTree(lli s,lli e,lli *arr, vector<lli> &tree,lli ind){
    // base
    if(s==e){
        // at the leaf node
        tree[ind] = arr[s];
        return;
    }
    // recurse
    lli mid = (s+e)/2;
    buildTree(s,mid,arr,tree,2*ind);
    buildTree(mid+1,e,arr,tree,2*ind+1);
    tree[ind] = (tree[2*ind] ^ tree[2*ind+1]);
    return;
}
lli queryTree(lli l,lli r ,lli s,lli e,vector<lli> &tree,lli ind){
    //base
    if(s > r || e < l)
        return 0; // as x xor 0 is just x
    if(s>=l && e<=r){
        return tree[ind];
    }
    // recurse
    lli mid = (s+e)/2;
    lli left = queryTree(l,r,s,mid,tree,2*ind);
    lli right = queryTree(l,r,mid+1,e,tree,2*ind+1);
    return (left^right);
}
// let's just not take lazy and try it

void updateTree(lli s,lli e,lli i,lli val, vector<lli> &tree,lli ind){
    //base
    // function signature ->
    // val : it is the value with which
    // you wanna replace a[i].
    if(s == e && i==s){
        tree[ind] = val;
        return;
    }
    if(i < s || i > e)
        return;
    //reurse
    lli mid = (s+e)/2;
    updateTree(s,mid,i,val,tree,2*ind);
    updateTree(mid+1,e,i,val,tree,2*ind+1);
    tree[ind] = tree[2*ind] ^ tree[2*ind+1];
    return;
}
int main(){
    ios::sync_with_stdio(0);
    in(n);
    in(q);
    lli t,x,y;
    lli arr[n];
    for0(n)
        cin>>arr[i];
    vector<lli> tree(4*300005);
    buildTree(0,n-1,arr,tree,1LL);
    while(q--){
        cin>>t>>x>>y;
        if(t==1){
            updateTree(0,n-1,x-1,(arr[x-1] ^ y),tree,1LL);
            arr[x-1] ^= y;
        }
        else{
            cout<<queryTree(x-1,y-1,0,n-1,tree,1LL)<<endl;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define int long long

namespace IO {
	const int N = 2e6;
	char buf[N], *p1 = buf, *p2 = buf;
	inline char gc() {
		if(p1 == p2) p2 = (p1 = buf) + fread(buf, 1, N, stdin);
		return p1 == p2 ? EOF : *(p1 ++);
	}
	template <typename T>
	inline void read(T &x) {
		x = 0; bool f = 0; char a = gc(); 
		for(; ! isdigit(a); a = gc()) if(a == '-') f = 1; 
		for(; isdigit(a); a = gc()) x = x * 10 + (a ^ 48); 
		if(f) x = -x; 
	}
	inline int read() { int x; read(x); return x; }
	inline LL readll() { LL x; read(x); return x; }
	inline char readchar() {
		char a = gc();
		while(a == ' ' || a == '\n') a = gc(); return a;
	}
	inline int reads(char *s) {
		char *O = s, a = gc();
		while(! isalpha(a) && ! isdigit(a)) a = gc();
		while(isalpha(a) || isdigit(a)) *O = a, O ++, a = gc();
		return O - s;
	}
	inline void outs(int len, char *s, char ch = '\n') {
		char *O = s;
		while(len --) putchar(*O), O ++; putchar(ch);
	}
	char Of[105], *O1 = Of, *O2 = Of;
	template <typename T>
	inline void print(T n, char ch = '\n') {
		if(n < 0) putchar('-'), n = -n;
		if(n == 0) putchar('0');
		while(n) *(O1 ++) = (n % 10) ^ 48, n /= 10;
		while(O1 != O2) putchar(*(-- O1));
		putchar(ch);
	}
}

using IO :: read;
using IO :: print;
using IO :: reads;
using IO :: outs;
using IO :: readchar;

const int N = 2e5 + 10;

int A, B, C;

vector<int> find(int x, int p) {
	x %= p;
	map<int, int> mp;
	vector<int> res;
	int t = 1;
	while(1) {
		t = (LL) t * x % p;
		if(mp[t]) return res;
		res.push_back(t);
		mp[t] = 1;
	}
}

int power(int x, int k, int P) {
	int res = 1;
	while(k) {
		if(k & 1) res = (LL) res * x % P;
		x = (LL) x * x % P; k >>= 1;
	} return res;
}

signed main() {
	#ifdef IN
	freopen("a.in", "r", stdin); 
	//freopen("a.out", "w", stdout);
	#endif
	A = read(); B = read(); C = read();
	vector<int> p1 = find(A, 10);
	B = power(B, C, p1.size());
	B --;
	if(B < 0) B += p1.size();
	print(p1[B]);
	/*vector<int> p2 = find(B, p1.size());
	
	C %= p2.size();
	C --;
	if(C < 0) C += p2.size();
	
	int v = p2[C];
	v %= p1.size();
	
	v --;
	if(v < 0) v += p1.size();
	v = p1[v];
	print(v % 10);*/
	
	return 0;
}