// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const long double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin>>n>>m;
	vvi G(n,vi(n));
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a][b]=G[b][a]=1;
	}
	int N=1<<n;
	vi dp(N,inf);
	dp[0]=0;
	rep(i,N){
		for(int j=i;j>0;j=(j-1)&i){
			cmin(dp[i],dp[j]+dp[i-j]);
		}
		bool h=true;
		rep(j,n)rep(k,n)if(k-j&&(i&1<<j)&&(i&1<<k)&&G[j][k]==0)
			h=false;
		if(h)dp[i]=1;
	}
	cout<<dp.back()<<endl;
}

#include <bits/stdc++.h>
//#include "debugger.h"
#define int long long
#define pb push_back
#define pp pop_back
#define f first
#define s second
#define all(x) x.begin(),x.end()
using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int q;
	cin >> q;
	
	int flag = 0;
	while (q--) {
		int t, a, b;
		cin >> t >> a >> b;
		
		if (t == 1) {
			if (flag) {
				a -= 1;
				b -= 1;
				if (a >= n)	a = a - n;
				else 		a = a + n;
					
				if (b >= n)	b = b - n;
				else 		b = b + n;
					
				swap(s[a], s[b]);
			}
			else {
				swap(s[a - 1], s[b - 1]);
			}
		}
		else {
			flag = 1 - flag;
		}
		// cout << s << "\n";
	}
	
	if (flag) 
		s = s.substr(n) + s.substr(0, n);
	
	cout << s;
	
	return 0;
}
