#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repn(i, n) for (int i = (int)(n)-1; i>= 0; --i)
#define ll long long
using Graph = vector<vector<int>>;
int main(){
    int n, Q, cnt = 0;
    string s;
    cin >> n >> s >> Q;
    rep(q, Q){
        int t, a, b;
        cin >> t >> a >> b;
        a--;
        b--;
        if (t == 1){
            if (cnt%2 == 0){
                char tmp = s[a];
                s[a] = s[b];
                s[b] = tmp;
            }
            else {
                if (a >= n) {
                    a -= n;
                    b -= n;
                }
                else if (b < n){
                    a += n;
                    b += n;
                }
                else {
                    a += n;
                    b -= n;
                }
                char tmp = s[a];
                s[a] = s[b];
                s[b] = tmp;
            }
        }
        else cnt++;
    }
    if (cnt%2 == 1){
        string tmp;
        s = s.substr(n, n) + s.substr(0, n);
    }
    cout << s << endl;
}
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int N=25;

int a[N],n;
int ans=(1<<30)+1;
int idx[N],cnt;

void dfs(int rank){
	if(rank==n) {
		idx[cnt++]=n;
		int l,r,h,w;
		h=0;
		l=0;
		for(int i=0;i<cnt;i++){
			r=idx[i];
			w=0;
			for(int j=l;j<=r;j++) {
				w|=a[j];
			}
			h^=w;
			l=r+1;
		}
		ans=min(ans,h);
		cnt--;
		return ;
	}
	idx[cnt++]=rank;
	dfs(rank+1);
	cnt--;
	dfs(rank+1);
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	cnt=0;
	dfs(1);
	cout<<ans<<endl;
	return 0;
}