#include <bits/stdc++.h>  // This will work only for g++ compiler. 


#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())


using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
    
    ll t,n,i,j,k,l,q,a,b;
    string s;
    ll z=0;
    cin>>n>>s>>q;
    while(q--){ 
        cin>>t>>a>>b;
        if(t==2)z++;
        if(t==1){
            if(z%2==1){
                if(a<=n)
                a=a+n;
                else 
                a=a-n;
                if(b<=n)
                b=b+n;
                else
                b=b-n;

                b--;
                a--;

                swap(s[a],s[b]);
            }
            else{
                swap(s[a-1],s[b-1]);
            }
        }
    }
    if(z%2==1){
        for(i=n;i<2*n;i++)cout<<s[i];
        for(i=0;i<n;i++)cout<<s[i];
    }
    else{
        cout<<s;
    }
}
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }


int N, X;
int A[51];

map<int, int> _memo[51];
int ans = 0;

void func(int depth)
{
	if (depth == N - 1)
	{
		for (auto p : _memo[depth])
		{
			if (p.first % A[depth] == 0)
			{
				ans += p.second;
			}
		}
	}
	else
	{
		for (auto p : _memo[depth])
		{
			int n = p.first;
			int cnt = p.second;

			int m = n % A[depth + 1];
			if (m == 0)
			{
				_memo[depth + 1][n] += cnt;
			}
			else
			{
				_memo[depth + 1][n - m] += cnt;
				_memo[depth + 1][n + (A[depth + 1] - m)] += cnt;
			}
		}

		func(depth + 1);
	}
}



signed main()
{
	cin >> N >> X;
	REP(i, N) cin >> A[i];

	_memo[0][X] = 1;
	func(0);

	cout << ans << endl;
}
