/**
*    author:  tomo0608
*    created: 22.05.2021 20:58:10
**/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include<atcoder/all>
using namespace atcoder;
#endif

typedef long long ll;
typedef long double ld;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;

#define all(x) x.begin(),x.end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
template<class... T>void input(T&... a){(cin >> ... >> a);};
#define INT(...) int __VA_ARGS__; input(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
#define STRING(...) string __VA_ARGS__; input(__VA_ARGS__)
void print(){cout << '\n';}
template<class T, class... Ts>void print(const T& a, const Ts&... b){cout << a; (cout << ... << (cout << ' ', b)); cout << '\n';}
template<class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {os << "{"; for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {os << *itr;++itr;if(itr != set_var.end()) os << ", ";itr--;}os << "}";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) {os << "{";for(auto itr = map_var.begin(); itr != map_var.end(); itr++) {os << *itr;itr++;if (itr != map_var.end()) os << ", ";itr--;}os << "}";return os;}
#ifdef __LOCAL
void debug_out(){ cerr << endl;}
template < class Head, class... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
template<class T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
#define pb push_back
#define eb emplace_back
#define elif else if
#define mp make_pair
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template<typename T> T gcd(T x, T y){if(x%y == 0)return y;return gcd(y, x%y);}
template<typename T> T gcd(vector<T> a){T res = a[0];for(auto &x: a)res = gcd(res, x);return res;}
template <typename T>T mypow(T x, ll n){T ret = 1;while(n > 0){if(n & 1)(ret *= x);(x *= x);n >>= 1;}return ret;}
#define endl '\n'
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};


void solve(){
    INT(n);
    V<int> a(n),b(n),c(n);cin >> a >> b >> c;
    V<ll> A(n+1,0),B(n+1,0);
    rep(i,n){
        A[a[i]]++;
        B[b[c[i]-1]]++;
    }
    ll ans = 0;
    rep(i,n+1)ans += A[i]*B[i];
    print(ans);
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << setprecision(20);
    int codeforces = 1;
    //cin >> codeforces;
    while(codeforces--){
        solve();
    }
    return 0;
}
                                /****Jai Ganesha Deva****/
#include<bits/stdc++.h>
using namespace std ;
 
#define int             long long 
#define sz(a)           (int)a.size()
#define INF             2000000000000000000
#define double          long double
#define bug(x)          cerr<<#x<<" is "<<x<<endl
#define debug(...)      fprintf(stderr, __VA_ARGS__), fflush(stderr)
const int M          =  1000000007;
const int MM         =  998244353;
const double PI      =  acos(-1);
 
int tError()
{   
    int n;cin>>n;n*=2;
    string s;cin>>s;
    int q;cin>>q;
    int state =0;

    while(q--)
    {
    	int t,a,b;cin>>t>>a>>b;a--;b--;
    	if(t==2)state = !state;

    	else 
    	{	
    		if(state==0)
    		swap(s[a],s[b]);
    		else
    		{
    			if(a>=n/2)
    				a=a-n/2;
    			else 
    				a=a+n/2;

    			if(b>=n/2)
    				b=b-n/2;
    			else 
    				b=b+n/2;
    			
    			swap(s[a],s[b]);
    		}
    	}
    }

    if(state ==0)cout<<s;
    else 
    {
    	for (int i = 0; i < n/2; ++i)
    	{
    		/* code */
    		swap(s[i],s[n/2+i]);
    	}
    	cout<<s;
    }
    return 0;
}
 
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt" ,"r",stdin) ;
    freopen("output.txt","w",stdout);
    #endif
  */    
    int TESTS=1 ;
  //  cin>>TESTS;
    while(TESTS--){
        tError();
        }
        
    //clock_t z=clock();
    //debug("Total Time:%.4Lf\n",(double)(clock()-z)/CLOCKS_PER_SEC);

    return 0   ;
}