#include <bits/stdc++.h>
#include <chrono>
#include <ctime>
using namespace std;
using namespace chrono;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
typedef vector<vector<int>> state;


bool is_spread(int id);
void fill(double dur, int width);
void init();
void adinit(int id);
void output();
void update(int id, int asp, int width);
int score();


struct d1{
    int x, y, r;
};


const int EDGE = 10000;
const double tlimit = 4700;
const double ideal_rate = 0.98;
double ntime;
double Stime;
int n;
int weightsum = 0;
vector<d1> req(200);
state ans(200, vector<int>(4));
vector<int> area(200);
vector<int> ideal(200);
vector<int> weight(EDGE*EDGE);
vector<bool> expandable(200, true);

random_device seed;
mt19937_64 gen(seed());



int main(){
    Stime = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
    ntime = Stime;
    init();

    fill(tlimit, 2);

    output();
    return 0;
}



void fill(double dur, int width){
    double endtime = Stime + dur;
    while(ntime < endtime){
        ntime = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
        int id = gen() % n;
        if(area[id] > ideal[id] || !expandable[id])continue;
        int asp = gen() % 4;
        update(id, asp, width);
    }
}


void update(int id, int asp, int width = 1){
    bool ok = false;
    rep(i,4){
        int dir = (asp+i) % 4;
        int ramda = 1;
        if(dir <= 1){
            if(ans[id][dir] - width < 0)continue;
        }else{
            if(ans[id][dir] + width > EDGE)continue;
            ramda = -1;
        }
        ans[id][dir] -= width*ramda;
        if(is_spread(id)){
            int height = 0;
            if(dir % 2 == 0)height = ans[id][3] - ans[id][1];
            else height = ans[id][2] - ans[id][0];
            area[id] += width * height;
            ok = true;
        }else{
            ans[id][dir] += width*ramda;
        }
    }

    if(!ok)expandable[id] = false;

}


bool is_spread(int id){
    bool res = true;
    rep(i,n){
        if(i == id)continue;
        if(! (ans[id][2] <= ans[i][0] || ans[i][2] <= ans[id][0] ||
                    ans[id][3] <= ans[i][1] || ans[i][3] <= ans[id][1]) )res = false;
    }
    return res;
}


int score(){
    double sat = 0;
    rep(i,n){
        if(ans[i][0] <= req[i].x && req[i].x < ans[i][2] &&
                ans[i][1] <= req[i].y && req[i].y < ans[i][3]){
            int s = (ans[i][2] - ans[i][0]) * (ans[i][3] - ans[i][1]);
            double t = 1 - (double)min(req[i].r, s)/(double)max(req[i].r, s);
            sat += 1 - t*t;
        }
    }
    sat /= n;
    return (int)1e9 * sat;
}


void init(){
    cin >> n;
    rep(i,n){
        cin >> req[i].x >> req[i].y >> req[i].r;
        adinit(i);
        ideal[i] = req[i].r * ideal_rate;
    }
}


void adinit(int id){
    ans[id][0] = req[id].x;
    ans[id][1] = req[id].y;
    ans[id][2] = req[id].x + 1;
    ans[id][3] = req[id].y + 1;
    area[id] = 1;
}


void output(){
    rep(i,n){
        rep(j,4){
            if(j != 0)cout << ' ';
            cout << ans[i][j];
        }
        cout << "\n";
    }
}

#include<bits/stdc++.h>
#define int long long
#define ll long long
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fs first
#define sd second
#define rept(x,n) for(int i=x;i<n;i++)
#define rrept(n,x) for(int i=n-1;i>=x;i--)
#define all(v) v.begin(),v.end()
#define mpit map<int,int>::iterator
#define stit set<int,int>::iterator
#define quit queue<int,int>::iterator
#define maxt(a,b,c) max(a,max(b,c))
#define mint(a,b,c) min(a,min(b,c))
#define rsort(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define printarr(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";cout<<"\n";
#define printvec(v) for(int i = 0;i<v.size();i++)cout<<v[i]<<" ";cout<<"\n";
using namespace std;
using namespace std::chrono;
ll power(ll a,ll b){ll res = 1;while(b){if(b&1)res*=a;a*=a;b/=2;}return res;}
ll powerwithmod(ll a,ll b,ll mod){ll res = 1;while(b){if(b&1)res*=a;res%=mod;a*=a;a%=mod;b/=2;}return res;}
void sieve(vector<ll>&prime,ll n){ll contestant[n+1]={0};contestant[0]=1;contestant[1]=1;contestant[2]=0;
for(ll i = 4;i<=n;i+=2)contestant[i]=1;for(ll i = 3;i*i<=n;i+=2){if(contestant[i]==0){
for(ll j = i*i;j<=n;j+=i){contestant[j] = 1;}}}for(ll i = 2;i<=n;i++){if(contestant[i]==0)prime.pb(i);}}

/*-------------------------------------------------------------------------------------------------------*/

void solve()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll q;
	cin>>q;
	ll cnt2=0;
	while(q--)
	{
		ll t,a,b;
		cin>>t>>a>>b;
		if(t==2)
		{
			cnt2^=1;
		}
		else
		{
			if(cnt2==0)
				swap(s[a-1],s[b-1]);
			else
			{
				if(a<=n&&b<=n)
				{
					swap(s[n+a-1],s[n+b-1]);
				}
				else if(a>n&&b>n)
				{
					swap(s[a-1-n],s[b-1-n]);
				}
				else
				{
					swap(s[n+a-1],s[b-1-n]);
				}
			}
		}
	}
	if(cnt2==1)
	{
		for(ll i = n;i<2*n;i++)
			cout<<s[i];
		for(ll i = 0;i<n;i++)
			cout<<s[i];
	}
	else
		cout<<s<<"\n";
}
signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
	#endif
    speed;
    int t=1;
    //cin>>t;
	auto start = high_resolution_clock::now();
    while(t--)
    {
         solve();
    }
	auto stop = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
	cerr << "Time: " << duration.count()/1000.0 << endl;
#endif
	return 0;
}
