#define _USE_MA_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }

int N;
int X[200001];
int Y[200001];
int M;
int Q;

const int PLUS_X = 1;
const int MINUS_X = -1;
const int PLUS_Y = 2;
const int MINUS_Y = -2;

struct Op
{
	int p;
	int f;
};

Op _op_x[200001];
Op _op_y[200001];

int func(Op op, int x, int y)
{
	int ret = 0;

	if (op.f == PLUS_X)
	{
		ret = x;
	}
	if (op.f == MINUS_X)
	{
		ret = -x;
	}
	if (op.f == PLUS_Y)
	{
		ret = y;
	}
	if (op.f == MINUS_Y)
	{
		ret = -y;
	}

	ret += op.p;
	return ret;
}

signed main()
{
	cin >> N;
	REP(i, N) cin >> X[i] >> Y[i];

	_op_x[0].p = 0;
	_op_x[0].f = PLUS_X;
	_op_y[0].p = 0;
	_op_y[0].f = PLUS_Y;

	cin >> M;
	for (int i = 1; i <= M; i++)
	{
		int o;
		cin >> o;
		if (o == 1)
		{
			_op_x[i].p = _op_y[i - 1].p;
			_op_x[i].f = _op_y[i - 1].f;
			_op_y[i].p = -_op_x[i - 1].p;
			_op_y[i].f = -_op_x[i - 1].f;
		}
		else if (o == 2)
		{
			_op_x[i].p = -_op_y[i - 1].p;
			_op_x[i].f = -_op_y[i - 1].f;
			_op_y[i].p = _op_x[i - 1].p;
			_op_y[i].f = _op_x[i - 1].f;
		}
		else if (o == 3)
		{
			int p;
			cin >> p;
			_op_x[i].p = 2 * p - _op_x[i - 1].p;
			_op_x[i].f = -_op_x[i - 1].f;
			_op_y[i].p = _op_y[i - 1].p;
			_op_y[i].f = _op_y[i - 1].f;
		}
		else if (o == 4)
		{
			int p;
			cin >> p;
			_op_x[i].p = _op_x[i - 1].p;
			_op_x[i].f = _op_x[i - 1].f;
			_op_y[i].p = 2 * p - _op_y[i - 1].p;
			_op_y[i].f = -_op_y[i - 1].f;
		}
	}

	cin >> Q;
	REP(i, Q)
	{
		int a, b;
		cin >> a >> b;

		Op opx = _op_x[a];
		Op opy = _op_y[a];
		int x = X[b - 1];
		int y = Y[b - 1];

		int nx = func(opx, x, y);
		int ny = func(opy, x, y);

		cout << nx << " " << ny << endl;
	}
}



#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
inline int read(){
	int X=0;bool flag=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')flag=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag)return X;
	return ~(X-1);
}
int n,a[510][510],ansa[510],ansb[510],minn=1e9+7,minnn=1e9+7;
inline bool check(){
	for(int i=2;i<=n;i++){
		ansa[i]=a[i][1]-ansb[1],ansb[i]=a[1][i]-ansa[1];
		if(ansa[i]<0||ansb[i]<0)return 0;
	}
	for(int i=2;i<=n;i++)
	for(int j=2;j<=n;j++)
	if(ansa[i]+ansb[j]!=a[i][j])return 0;
	return 1;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++){
		a[i][j]=read();
		if(i>1&&j>1)
		if((a[i][j]+a[i-1][j]+a[i][j-1]+a[i-1][j-1])&1){
			puts("No");
			return 0;
		}
	}
	for(int i=1;i<=n;i++)minn=min(minn,a[1][i]),minnn=min(minnn,a[i][1]);
	for(int k=minn;k>=0;k--){
		if(a[1][1]-k<minnn)continue;
		ansa[1]=k,ansb[1]=a[1][1]-k;
		if(check()){
			puts("Yes");
			for(int i=1;i<=n;i++)printf("%d ",ansa[i]);
			puts("");
			for(int i=1;i<=n;i++)printf("%d ",ansb[i]);
			return 0;
		}
		ansa[1]=a[1][1]-k,ansb[1]=k;
		if(check()){
			puts("Yes");
			for(int i=1;i<=n;i++)printf("%d ",ansa[i]);
			puts("");
			for(int i=1;i<=n;i++)printf("%d ",ansb[i]);
			return 0;
		}
	}
	puts("No");
	return 0;
}