#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define N 100009
int val[N], ch[N][2], fa[N], lazy[N], sum[N];
inline void updata(int x)
{
sum[x] = sum[ch[x][0]] ^ sum[ch[x][1]] ^ val[x];
}
inline void swap(int& a, int& b)
{
int c = a;a = b, b = c;
}
inline void pushdown(int x)
{
if (lazy[x])
{
swap(ch[x][1], ch[x][0]);
if (ch[x][0])
lazy[ch[x][0]] ^= 1;
if (ch[x][1])
lazy[ch[x][1]] ^= 1;
lazy[x] = 0;
}
}
inline bool isRoot(int x)
{
return x != ch[fa[x]][1] && x != ch[fa[x]][0];
}
inline bool get(int x)
{
return x == ch[fa[x]][1];
}
void Updata(int x)
{
if (!isRoot(x))
Updata(fa[x]);
pushdown(x);
}
inline void rorate(int x)
{
int y = fa[x], z = fa[y], fy = get(x), fz = get(y);
int cur = ch[x][!fy];
fa[x] = z;
if (!isRoot(y))
ch[x][fz] = z, fa[z] = x;
ch[cur][fy] = y, fa[y] = cur;
ch[y][!fy] = x, fa[x] = y;
updata(y), updata(x);
}
inline void splay(int x)
{
Updata(x);
while (!isRoot(x))
{
if (!isRoot(fa[x]))
rorate(get(fa[x]) == get(x) ? x : fa[x]);
rorate(x);
}
updata(x);
}
inline void access(int x)
{
for (int y = 0 ; x ; x = fa[y = x])
splay(x), ch[x][1] = y, updata(x);
}
inline void makeroot(int x)
{
access(x), splay(x), lazy[x] ^= 1, pushdown(x);
}
inline int findroot(int x)
{
access(x), splay(x);
pushdown(x);
while (ch[x][0])
pushdown(x = ch[x][0]);
return x;
}
inline void split(int x, int y)
{
makeroot(x);
access(y), splay(y);
}
inline void link(int x, int y)
{
makeroot(x);
if (findroot(y) != x)
fa[x] = y;
}
inline void cut(int x, int y)
{
makeroot(x);
if (findroot(y) == x && fa[x] == y && ch[y][0] == x && !ch[x][1])
fa[x] = ch[y][1] = 0, updata(x);
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1;i <= n;++ i)
scanf("%d", &val[i]);
int opt, x, y;
while (m --)
{
scanf("%d%d%d", &opt, &x, &y);
if (opt == 0)
split(x, y), printf("%d\n", sum[x]);
if (opt == 1)
link(x, y);
if (opt == 2)
cut(x, y);
if (opt == 3)
splay(x), val[x] = y;
}
return 0;
}