#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define irreps(i, m, n) for (int i = ((int)(n)-1); i > (int)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (int)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;
using ld = long double;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll LINF = 1e18;


void fail(){
  cout << "No" << endl;
  exit(0);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  int n; cin>>n;
  vc<vc<int>> c(n, vc<int>(n));
  rep(i,n) rep(j,n) cin>>c[i][j];
  
  vc<int> a(n), b(n);
  int minb=INF;
  rep(i,n){
    b[i]=c[i][0];
    chmin(minb,b[i]);
  }
  int mina=INF;
  rep(j,n){
    a[j]=c[j][j]-b[j];
    chmin(mina,a[j]);
  }
  
  rep(i,n){
    rep(j,n){
      if(b[i]+a[j]!=c[i][j]) {
        fail();
      }
    }
  }
  
  if(mina<0){
    if(abs(mina)>abs(minb)) fail();
    int x=abs(mina);
    rep(i,n) a[i]+=x, b[i]-=x;
  }
  
  cout<<"Yes"<<endl;
  swap(a,b);
  rep(i,n) cout<<a[i]<<' ';
  cout<<endl;
  rep(i,n) cout<<b[i]<<' ';
  cout<<endl;
  
}
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pll pair<long long, long long>
#define f first
#define s second
#define debug cout<<"here\n" 
#define MOD 1000000009
 
using namespace std;
const int MAXN = 2e6 + 5;

int where[MAXN];

void solve(){
	int n; cin>>n;	
	for(int i=0; i<2*n; i++) where[i] = i;
	string s,ss; cin>>s;
	ss = s;
	int q; cin>>q;
	bool x = 0;
	while(q--){
		int ct,a,b; cin>>ct;
		if(ct == 1){
			cin>>a>>b; a--; b--;
			swap(where[(a+n*x)%(2*n)], where[(b+n*x)%(2*n)]);
		}
		else{
			x ^= 1;
			cin>>a>>b;
		}
	}
	for(int i=0; i<2*n; i++) ss[i] = s[where[i]];
	if(x){
		for(int i=n; i<2*n; i++) cout<<ss[i];
		for(int i=0; i<n; i++) cout<<ss[i];
	}
	else{
		cout<<ss;
	}
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cout.tie(0); cin.tie(0);	
	cout<<fixed<<setprecision(12);

	int t =1; //cin>>t;
	for(int i=1; i<= t; i++){
		solve();
		cout<<"\n";
	}
	
	return 0;
}