//如题
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define maxn 500020
using namespace std;
int read(){
char c=getchar();int f=1,x=0;
for(;c>'9'||c<'0';c=getchar())if(c=='-')f=-1;
for(;c<='9'&&c>='0';c=getchar())x=x*10+c-'0';
return x*f;
}
int n,m,cl,T,ls[maxn*20],rs[maxn*20],s[maxn*20],rt[maxn],t[maxn],val[maxn];
int num,head[maxn],tot=1,nn,f[maxn][20],h[maxn],size[maxn],ff[maxn],vis[maxn];
struct edge{int v,next;}e[maxn*2];
void adde(int a,int b){e[tot].v=b,e[tot].next=head[a];head[a]=tot++;}
int find(int x){return ff[x]==x ? x : ff[x]=find(ff[x]);}
bool unio(int x,int y){
int dx=find(x),dy=find(y);
if(dx==dy)return false;
ff[dx]=dy,size[dy]+=size[dx];
return true;
}
void insert(int x,int& y,int l,int r,int id){
y=++num;ls[y]=ls[x],rs[y]=rs[x],s[y]=s[x]+1;
if(l==r)return ;
int mid=l+r>>1;
if(id>mid)insert(rs[x],rs[y],mid+1,r,id);
else insert(ls[x],ls[y],l,mid,id);
}
int query(int x,int y,int z,int fz,int l,int r,int k){
if(l==r)return t[l];
int mid=l+r>>1,sum=s[ls[x]]+s[ls[y]]-s[ls[z]]-s[ls[fz]];
if(sum>=k)return query(ls[x],ls[y],ls[z],ls[fz],l,mid,k);
else return query(rs[x],rs[y],rs[z],rs[fz],mid+1,r,k-sum);
}
void dfs(int u,int fa){
f[u][0]=fa,h[u]=h[fa]+1,vis[u]=1;insert(rt[fa],rt[u],1,nn,val[u]);
for(int i=1;i<=17;i++)f[u][i]=f[f[u][i-1]][i-1];
for(int v,i=head[u];i;i=e[i].next){
if((v=e[i].v)==fa)continue;
dfs(v,u);;
}
}
int lca(int a,int b){
if(h[a]>h[b])swap(a,b);
for(int i=17;i>=0;i--)if(h[f[b][i]]>=h[a])b=f[b][i];
if(a==b)return a;
for(int i=17;i>=0;i--){
if(f[a][i]==f[b][i])continue;
a=f[a][i],b=f[b][i];
}
return f[a][0];
}
void link(int a,int b){
int dx=find(a),dy=find(b);
if(size[dx]>size[dy])swap(a,b),swap(dx,dy);//a所在的树更小
unio(a,b);
adde(a,b),adde(b,a);
dfs(a,b);
}
int main(){
scanf("%d",&T);
n=read(),m=read(),cl=read();
for(int i=1;i<=n;i++)ff[i]=i,size[i]=1;
for(int i=1;i<=n;i++)val[i]=t[i]=read();
sort(t+1,t+1+n);nn=unique(t+1,t+1+n)-t-1;
for(int i=1;i<=n;i++)val[i]=lower_bound(t+1,t+1+nn,val[i])-t;
int a=0,b=0,c=0,g;
for(int i=1;i<=m;i++){
a=read(),b=read();
adde(a,b),adde(b,a);
unio(a,b);
}
for(int i=1;i<=n;i++)if(!vis[i])dfs(find(i),0);
char s[5];int ans=0;
while(cl--){
scanf("%s",s);
if(s[0]=='Q'){
a=read(),b=read(),c=read();
a^=ans,b^=ans,c^=ans;
g=lca(a,b);
printf("%d\n",ans=query(rt[a],rt[b],rt[g],rt[f[g][0]],1,nn,c));
}else {
a=read(),b=read();
a^=ans,b^=ans;
link(a,b);
}
}
return 0;
}