#include<cstdio>
#include<cctype>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define ren for(int i=first[x];i;i=next[i])
using namespace std;
const int BufferSize=1<<16;
char buffer[BufferSize],*head,*tail;
inline char Getchar() {
if(head==tail) {
int l=fread(buffer,1,BufferSize,stdin);
tail=(head=buffer)+l;
}
return *head++;
}
inline int read() {
int x=0,f=1;char c=Getchar();
for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
return x*f;
}
const int maxn=100010;
const int maxnode=2000010;
int n,m,pa[maxn],num[maxn];
int findset(int x) {return pa[x]==x?x:pa[x]=findset(pa[x]);}
int s[maxnode],ls[maxnode],rs[maxnode],root[maxn],ToT;
void insert(int& o,int l,int r,int pos) {
s[o=++ToT]=1;if(l==r) return;
int mid=l+r>>1;
if(pos<=mid) insert(ls[o],l,mid,pos);
else insert(rs[o],mid+1,r,pos);
}
int query(int o,int l,int r,int k) {
if(s[o]<k) return -1;
if(l==r) return l;
int mid=l+r>>1,k2=s[ls[o]];
if(k2>=k) return query(ls[o],l,mid,k);
return query(rs[o],mid+1,r,k-k2);
}
int merge(int x,int y) {
if(x*y==0) return x+y;
s[x]+=s[y];
ls[x]=merge(ls[x],ls[y]);
rs[x]=merge(rs[x],rs[y]);
return x;
}
void link(int x,int y) {
x=findset(x);y=findset(y);pa[y]=x;
if(x!=y) root[x]=merge(root[x],root[y]);
}
int main() {
n=read();m=read();
rep(i,1,n) {
int val=read();num[val]=i;
insert(root[pa[i]=i],1,n,val);
}
rep(i,1,m) link(read(),read());
dwn(i,read(),1) {
char c=Getchar();while(!isalpha(c)) c=Getchar();
if(c=='Q') {
int x=read(),k=read();
int ans=query(root[findset(x)],1,n,k);
printf("%d\n",ans<0?-1:num[ans]);
}
else link(read(),read());
}
return 0;
}