#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 998244353
using ll=long long;
using Graph=vector<vector<int>>;

int n=1;
vector<int> tree;
int solve(int a,int b,int i,int left,int right){
  if(b<=left||right<=a){
    return 0;
  }
  if(a<=left&&right<=b){
    return tree[i];
  }
  int x=solve(a,b,2*i+1,left,(left+right)/2);
  int y=solve(a,b,2*i+2,(left+right)/2,right);
  int res=x^y;
  return res;
}

void update(int i,int x){
  i+=n-1;
  tree[i]=x;
  while(i>0){
    i=(i-1)/2;
    tree[i]=tree[2*i+1]^tree[2*i+2];
  }
}

int main(){
  int N,Q;
  cin>>N>>Q;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  while(n<N){
    n<<=1;
  }
  tree.resize(2*n-1,0);
  for(int i=0;i<N;i++){
    tree[i+n-1]=A[i];
  }
  for(int i=n-2;i>=0;i--){
    tree[i]=tree[2*i+1]^tree[2*i+2];
  }

  for(int i=0;i<Q;i++){
    int T,X,Y;
    cin>>T>>X>>Y;
    if(T==1){
      X--;
      int y=tree[X+n-1];
      y^=Y;
      update(X,y);
    }else{
      int x=solve(X-1,Y,0,0,n);
      cout<<x<<'\n';
    }
  }
}

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<bitset>
#include<deque>
#include<cstdlib>
#include<set>
#include<ctime>
#define ll long long
#define mp make_pair
using namespace std;
ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return f*x;
}
int mts[12];
ll A,B,C;
ll pow_mod(ll a,ll b,ll mod)
{
	ll ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	for(int i=2;i<=9;++i)
	{
		int num=1,tmp=i;
		num++;
		tmp=tmp*i%10;
		while(tmp!=i)
		{
			num++;
			tmp=tmp*i%10;
		 } 
		mts[i]=num;
	//	cout<<i<<": "<<mts[i]<<'\n';
	}
	A=read(),B=read(),C=read();
	if(A%10==1) cout<<1<<'\n';
	else if(A%10==0) cout<<0<<'\n';
	else 
	{
		ll tmp=pow_mod(B,C,mts[A%10]-1);
	//	cout<<tmp<<'\n';
		if(!tmp) tmp+=mts[A%10]-1;
		cout<<pow_mod(A,tmp,10)<<'\n';

		
	}
	return 0;
 }
