C++#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int n,a[300005],m,l=100001,r;
bool ok;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("seq.in","r",stdin);
// freopen("seq.out","w",stdout);
cin>>n;
r=l+n-1;
for(int i=l;i<=r;i++)cin>>a[i];
cin>>m;
while(m--){
int f;
int x;
cin>>f;
if(f==1){
cin>>x;
if(ok){
a[++r]=x;
}
else a[--l]=x;
}
else if(f==2){
cin>>x;
if(!ok){
a[++r]=x;
}
else a[--l]=x;
}
else ok=!ok;
}
if(ok){
for(int i=r;i>=l;i--){
cout<<a[i]<<" ";
}
}
else{
for(int i=l;i<=r;i++){
cout<<a[i]<<" ";
}
}
return 0;
}