#include<bits/stdc++.h>
#define W while
#define RI int
#define Cn const
#define CI Cn int& 
#define I inline
using namespace std;
Cn int N=2e6+10,M=610;
int Tt,op,n,m,k,a[N],cnt;
deque<int> sk[N];
#define pb push_back
I void U(CI x){
	++cnt;if(!sk[x].empty()&&sk[x].back()==a[cnt]) return sk[x].pop_back(),void();
	sk[x].pb(a[cnt]);
}
I void V(CI x,CI y){
	!(!sk[x].empty()&&!sk[y].empty()&&sk[x].front()==sk[y].front())&&(
	cerr<<sk[x].size()<<" "<<sk[y].size()<<"\n",
	cerr<<x<<" "<<y<<" "<<sk[x].front()<<" "<<sk[y].front()<<'\n',0);
	assert(!sk[x].empty()&&!sk[y].empty()&&sk[x].front()==sk[y].front());
	sk[x].pop_front(),sk[y].pop_front();
}
int main(){
	freopen("1.in","r",stdin);
	cin>>n>>m>>k;RI i,op,x,y,Qt;for(i=1;i<=m;i++) cin>>a[i];
	cin>>Qt;W(Qt--) cin>>op>>x,op&1?U(x):(cin>>y,V(x,y));
	assert(cnt==m);
	for(i=1;i<=n;i++) assert(sk[i].empty());
}