#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<array<int, 3>> A(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i][0] >> A[i][1] >> A[i][2];
    }
    vector<int64_t> dp(1<<N);
    dp[0] = 1;
    for (int i = 0; i < (1 << N); i++) {
        int n = 0;
        vector<int> p(N + 1);
        for (int j = 0; j < N; j++) {
            if (i & (1 << j)) {
                p[j + 1] += 1;
                n += 1;
            }
            p[j + 1] += p[j];
        }
        for (int j = 0; j < N; j++) {
            if (i & (1 << j)) continue;
            int c = 1;
            for (int k = 0; k < M; k++) {
                if (A[k][0] <= n) continue;
                if (j + 1 <= A[k][1] && p[A[k][1]] >= A[k][2]) {
                    c = 0;
                    break;
                }
            }
            if (c) {
                dp[i | (1 << j)] += dp[i];
            }
        }
    }
    cout << dp[(1<<N) - 1];
}
#include <bits/stdc++.h>

#define rep(i, n) for (auto i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()

using namespace std;

using ll = long long int;

const int MOD_NUM = 1e9 + 7;

int main() {
    // Input
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<int> T(Q), A(Q), B(Q);
    rep(i, Q) cin >> T[i] >> A[i] >> B[i];

    // Process
    string ans(S);
    int reverse = 0;
    rep(i, Q) {
        if (T[i] == 1) {
            int a = A[i] - 1;
            int b = B[i] - 1;
            if (reverse % 2 == 1) {
                a = (a + N) % (N * 2);
                b = (b + N) % (N * 2);
            }

            char tmp = ans[a];
            ans[a] = ans[b];
            ans[b] = tmp;
        } else
            reverse++;
    }
    if (reverse % 2 == 1) {
        string tmp1 = ans.substr(N);
        string tmp2 = ans.substr(0, N);
        ans = tmp1 + tmp2;
    }

    // Output
    cout << ans << endl;

    return 0;
}
