#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define Rep(i,j,n) for (ll i=(ll)(j);i<=(ll)(n);++i)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int mod = 998244353;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

/*
ll ti=clock();
cout<<("Execution Time: %.4lf sec", 1.0 * (clock() - ti) / CLOCKS_PER_SEC)<<endl;
*/

int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll q;
  cin>>q;
  ll count_2=0;
  ll m=2*n;
  rep(i,q){
      ll t,a,b;
      cin>>t>>a>>b;
      if(t==1){
          ll A,B;
          A=(a-1+n*(count_2%2))%m;
          B=(b-1+n*(count_2%2))%m;
        //   cout<<A<<" "<<B<<endl;//debug
          char tmp;
          tmp=s[A];
          s[A]=s[B];
          s[B]=tmp;
      }
      else{
          count_2++;
        //   cout<<"t1:"<<t1<<" t2:"<<t2<<endl;//debug
      }
    //   print(s);//debug
  }
  if(count_2%2==1){
      string t;
    t=s.substr(n,n);
    s.erase(n);
    s=t+s;
  }
  print(s);
}
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include<cassert>
#include<stack>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
using namespace std;
using ll =long long;
#define rep(i,n)for(ll i=0;i<(n);i++)
const int mod = 1000000007;
const ll inf = 1e18 + 1;
//int ctoi(char c) {
//	if (c >= '0' && c <= '9') {
//		return c - '0';
//	}
//	return 0;
//}
//
ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
//ll lcm(ll a, ll b) {
//	return a * b / gcd(a, b);
//};
//fixed << setprecision(2)


///*Union Find*/
//#define MAX_N 200000
//#define MAX_M 200000
//vector<ll>par(MAX_N);
//vector<ll>ran(MAX_N);
//void init(ll N) {
//	rep(i, N) {
//		par[i] = i;
//		ran[i] = 0;
//	}
//}
//ll find(ll x) {
//	if (par[x] == x) {
//		return x;
//	}
//	else {
//		return par[x] = find(par[x]);
//	}
//}
//void unite(ll x,ll y) {
//	x = find(x);
//	y = find(y);
//	if (x == y)return;
//	if (ran[x] < ran[y]) {
//		par[x] = y;
//
//	}
//	else {
//		par[y] = x;
//		if (ran[x] == ran[y])ran[x]++;
//	}
//}
//bool same(ll x, ll y) {
//	return find(x) == find(y);
//}
////UnionFind

//dfs
//if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
//dfs

//桁和を求める
//ll digsum(ll n) {
//	ll res = 0;
//	while (n > 0) {
//		res += n % 10;
//		n /= 10;
//	}
//	return res;
//}
//桁和を求める
//cin,coutを早くする
//ios::sync_with_stdio(false);
//cin coutを早くする。

ll g1(ll s) {
	map<int, int>m;
	ll tmp = s;
	int n=1;
	tmp /= 10;
	while (tmp!=0) {
		tmp /= 10;
		n++;
	}
	//cout << n<<endl;
	rep(i, n) {
		ll b = s / pow(10, i);
		b %= 10;
		m[b]++;
	}
	ll x=0;
	for (int i = 9; i >= 0; i--) {
		while (true) {
			if (m[i] != 0) {
				x += i * pow(10, n-1);
				m[i]--;
				n--;
			}
			else {
				break;
			}
		}
	}
	return x;
}
ll g2(ll s) {
	map<int, int>m;
	ll tmp = s;
	int n = 1;
	tmp /= 10;
	while (tmp != 0) {
		tmp /= 10;
		n++;
	}
//	cout << n << endl;
	rep(i, n) {
		ll b = s / pow(10, i);
		b %= 10;
		m[b]++;
	}
	ll x = 0;
	for (int i = 0; i <= 9; i++) {
		while (true) {
			if (m[i] != 0) {
				x += i * pow(10, n - 1);
				m[i]--;
				n--;
			}
			else {
				break;
			}
		}
	}
	return x;

}
int main() {
	ios::sync_with_stdio(false);
	ll N, K;
	cin >> N >> K;
	ll a = N;
	rep(i, K) {
		a = g1(a) - g2(a);
	}
	cout << a;
}