#include <bits/stdc++.h>
using namespace std;
long long INF = 1LL<<60;
using ll = long long;
using vll = vector<ll>;
using mll = map<ll, ll>;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



int main(){
    ll N2; cin >> N2;
    string S, S0, S1;
    cin >> S;
    S0 = S.substr(0, N2);
    S1 = S.substr(N2, N2*2);

    ll Q; cin >> Q;
    rep(q, 0, Q){
        ll T; cin >> T;
        ll A, B; cin >> A >> B;
        if(T == 1){
            A--; B--;
            if(A < N2 && B < N2)
                swap(S0.at(A), S0.at(B));
            else if(A < N2)
                swap(S0.at(A), S1.at(B - N2));
            else if(B < N2)
                swap(S1.at(A - N2), S0.at(B));
            else
                swap(S1.at(A - N2), S1.at(B -  N2));
        }
        else if(T == 2){
            swap(S0, S1);
        }
    }
    cout << S0 << S1 << endl;
    return 0;
}

#include <bits/stdc++.h>
#include <cassert>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep3(i, a, b) for (ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok ? "Yes" : "No");
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
template <class T> void takeUnique(vector<T> &v) {
  auto last = std::unique(v.begin(), v.end());
  v.erase(last, v.end());
}
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int dxx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int dyy[] = {1, 1, 0, -1, -1, -1, 0, 1};
// clang++ -std=c++11 -stdlib=libc++

int a[5];
int main() {
  int ans = INF;
  rep(i, 4) {
    int b;
    cin >> b;
    chmin(ans, b);
  }
  cout << ans << endl;
  return 0;
}
