#include<bits/stdc++.h>
#define int ll
#define sz(x) int((x).size())
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
using namespace std;
using ll = long long;
using pi = pair<int,int>;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int minf = 0xc0c0c0c0c0c0c0c0;

int sumtreeA[200200<<1];
int sumtreeB[200200<<1];
int cnttreeA[200200<<1];
int cnttreeB[200200<<1];
int A[200200];
int B[200200];

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

    int n,m,q; cin>>n>>m>>q;
    using ti = tuple<int,int,int>;
    vector<ti> query(q);
    vector<int> zip;
    zip.reserve(q);
    zip.pb(0);
    for (auto &[t,x,y] : query) {
        cin>>t>>x>>y;
        zip.pb(y);
    }
    int sz = sz(zip);

    cnttreeA[sz] = n; cnttreeB[sz] = m;
    for (int i=sz-1; i; i--) cnttreeA[i] = cnttreeA[i<<1] + cnttreeA[i<<1|1];
    for (int i=sz-1; i; i--) cnttreeB[i] = cnttreeB[i<<1] + cnttreeB[i<<1|1];

    auto sumq = [&](int le, int ri, int *T) {
        int ret = 0;
        for (le+=sz, ri+=sz; le<=ri; le>>=1, ri>>=1) {
            if (le&1) ret += T[le++];
            if (~ri&1) ret += T[ri--];
        }
        return ret;
    };

    auto update = [&](int idx, int val, int *T) {
        for (idx+=sz; idx; idx>>=1) T[idx] += val;
    };

    sort(all(zip));
    zip.erase(unique(all(zip)), zip.end());

    int res = 0;
    for (auto &[t,x,y] : query) {
        int idx = lower_bound(all(zip), y) - zip.begin();

        if (t == 1) {
            if (A[x] == y) {
                cout<<res<<'\n';
                continue;
            }
            int iidx = lower_bound(all(zip), A[x]) - zip.begin();
            if (A[x] < y) {
                res += sumq(0, iidx, cnttreeB) * (y - A[x]);
                res += -sumq(iidx+1, idx-1, sumtreeB) + sumq(iidx+1, idx-1, cnttreeB) * y;
            }
            else {
                res += sumq(0, idx, cnttreeB) * (y - A[x]);
                res += sumq(idx+1, iidx-1, sumtreeB) - sumq(idx+1, iidx-1, cnttreeB) * A[x];
            }
            update(iidx, -1, cnttreeA);
            update(idx, 1, cnttreeA);
            update(idx, zip[idx], sumtreeA);
            update(iidx, -zip[iidx], sumtreeA);
            A[x] = y;
        }
        else {
            if (B[x] == y) {
                cout<<res<<'\n';
                continue;
            }
            int iidx = lower_bound(all(zip), B[x]) - zip.begin();
            if (B[x] < y) {
                res += sumq(0, iidx, cnttreeA) * (y - B[x]);
                res += -sumq(iidx+1, idx-1, sumtreeA) + sumq(iidx+1, idx-1, cnttreeA) * y;
            }
            else {
                res += sumq(0, idx, cnttreeA) * (y - B[x]);
                res += sumq(idx+1, iidx-1, sumtreeA) - sumq(idx+1, iidx-1, cnttreeA) * B[x];
            }
            update(iidx, -1, cnttreeB);
            update(idx, 1, cnttreeB);
            update(idx, zip[idx], sumtreeB);
            update(iidx, -zip[iidx], sumtreeB);
            B[x] = y;
        }
        cout<<res<<'\n';
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int N, Q;
string S;

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

  cin >> N >> S >> Q;
  int flipcnt = 0;
  rep(i, Q) {
    int T, A, B;
    cin >> T >> A >> B;
    A--;
    B--;
    if (T == 1) {
      if (flipcnt % 2 == 1) {
        A = (A + N) % S.size();
        B = (B + N) % S.size();
      }
      swap(S[A], S[B]);
    } else {
      flipcnt++;
    }
  }
  string res = "";
  res = S;
  if (flipcnt % 2 == 1) {
    res = res.substr(N, N) + res.substr(0, N);
  }
  cout << res << endl;
}