#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define PI 3.14159265359
#define mod 1000000007
#define ALL(a)  (a).begin(),(a).end()

int main(){
    int n,q;
    string s;
    int count = 0;
    cin >> n >> s >> q;
    rep(i,q){
        int t,a,b;
        cin >> t >> a >> b;
        if(t == 1){
            if(count % 2 == 0)swap(s[a-1],s[b-1]);
            else{
                if(a <= n)a+=n;
                else a-=n;
                if(b <= n)b+=n;
                else b-=n;
                swap(s[a-1],s[b-1]);
            }
        }
        else{
            count++;
        }
    }
    if(count % 2 == 1){
        cout << s.substr(n,n) + s.substr(0,n) << endl;
    }
    else cout << s << endl;
} 
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

long long solve(long long A, long long B, long long C) {
  vi loop;
  int now = A % 10;
  loop.push_back(now);
  while (true) {
    int next = (now * (A % 10)) % 10;
    int len = loop.size();
    if (next == loop[0])
      break;
    loop.push_back(next);
    now = next;
  }

  ll mod = loop.size();
  ll res = 1;
  while (C) {
    if (C & 1) {
      res = res * B % mod;
    }
    B = B * B % mod;
    C /= 2;
  }

  return loop[(res - 1 + mod) % mod];
}

// generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator)
int main() {
  long long A, B, C;
  std::cin >> A >> B >> C;
  auto ans = solve(A, B, C);
  std::cout << ans << std::endl;
  return 0;
}
