#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define M 1000000007
#define mod 998244353
#define pll pair<ll, ll>
#define f first
#define se second
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define pb push_back
#define rb pop_back
#define prdb(x) cout << fixed << setprecision(10) << x;
#define speed1 ios_base ::sync_with_stdio(false);
#define speed2 cin.tie(NULL);
#define endl "\n"
/************
 * fill the array with desired value
    fill(all(vec), 1);    
    
 *fills the dsu parent array consecutively starting from desired value
    iota(all(parent), 0); 

 * sort the vector and then make all elements unique
    sort(all(vec)); 
    vec.resize(unique(all(vec)) - vec.begin());  

************/
ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    ll z = power(x, y / 2);
    z = z * z;
    if (y & 1)
        return (z * x);
    return z;
}
ll solve(vector<ll> &v, ll ind)
{
    if (ind == -1)
        return 1;

    if (v[ind])
        return solve(v, ind - 1);
    return solve(v, ind - 1) + power(2, ind + 1);
}

int main()
{
    //#ifndef ONLINE_JUDGE
    //    freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    //#endif
    speed1;
    speed2;

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        ll n, i, j, k;
        cin >> n;
        vector<ll> v(n);

        for (i = 0; i < n; i++)
        {
            string s;
            cin >> s;
            if (s == "AND")
                v[i] = 1;
            else
                v[i] = 0;
        }

        cout << solve(v, n - 1) << endl;
    }
}
#include <bits/stdc++.h>

using namespace std;

#define closeSync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 400005;
const int INF = 0x3f3f3f3f;

char s[MAXN];
inline void solve()
{
    int n;
    cin >> n;
    string str;   cin >> str;
    str = " " + str;
    for (int i=1;i<=(n<<1);i++)
        s[i] = str[i];

    int q;
    cin >> q;
    bool sp = false;
    while (q--)
    {
        int t,a,b;
        cin >> t >> a >> b;
        if (a > b) swap(a,b);
        if (t == 1)
        {
            // || ()
            if (sp)
            {
                if ((a <= n && b <=n) )
                {
                    swap(s[n+a],s[n+b]);
                }
                else if (a>n && b>n)
                {
                    swap(s[a-n],s[b-n]);
                }
                else 
                {
                    swap(s[n+a],s[b-n]);
                }
            }
            else 
                swap(s[a],s[b]);
        }
        else 
            sp = !sp;
    }
    if (!sp)
    {
        for (int i=1;i<=(n<<1);i++)
        {
            cout << s[i];
        }
        cout << endl;
    }
    else 
    {
        for (int i=n+1;i<=(n<<1);i++)
            cout << s[i];
        for (int i=1;i<=n;i++)
            cout << s[i];
        cout << endl;
    }

    return ;
}

int main()
{closeSync;
    // int T;
    // cin >> T;
    // while (T--)
        solve();
    return 0;
}

/*
3 4 4
GPLT
PATA
OMSA
*/