#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
#define VT vector
typedef VT<int> VI;
typedef VT<VI> VVI;
typedef VT<string> VS;
typedef VT<double> VD;
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define MP make_pair
#define FS first
#define SC second
#define SZ size()

void move_right(vector<vector<pair<int, int>>>& ref_right, vector<vector<pair<int, int>>>& ref_down, int& a, int& b)
{
	pair<int, int> next = ref_right[a][b];
	int i = next.first;
	int j = next.second;

	a = i;
	b = j;
}

void move_down(vector<vector<pair<int, int>>>& ref_right, vector<vector<pair<int, int>>>& ref_down, int& a, int& b)
{
	pair<int, int> next = ref_down[a][b];
	int i = next.first;
	int j = next.second;

	a = i;
	b = j;
}

pair<int, int> go(vector<vector<pair<int, int>>>& ref_right, vector<vector<pair<int, int>>>& ref_down, int a, int b)
{
	int i = 0;
	int j = 0;

	REP(t, a)
		move_down(ref_right, ref_down, i, j);

	REP(t, b)
		move_right(ref_right, ref_down, i, j);

	return make_pair(i, j);
}

void change_stripes(vector<vector<pair<int, int>>>& ref_right, vector<vector<pair<int, int>>>& ref_down, int h, int w,
	vector<pair<int,int>>& o1, vector<pair<int, int>>& l1, vector<pair<int, int>>& o2, vector<pair<int, int>>& l2)
{

	for (int cnt = 0; cnt < h; ++cnt)
	{
		int i1 = o1[cnt].first, j1 = o1[cnt].second;
		int i2 = l1[cnt].first, j2 = l1[cnt].second;

		ref_right[i1][j1] = MP(i2, j2);
	}

	for (int cnt = 0; cnt < w; ++cnt)
	{
		int i1 = o2[cnt].first, j1 = o2[cnt].second;
		int i2 = l2[cnt].first, j2 = l2[cnt].second;
		ref_down[i1][j1] = MP(i2, j2);
	}

}

vector<pair<int, int> > eval_down(vector<vector<pair<int, int>>>& ref_right, vector<vector<pair<int, int>>>& ref_down, int h, pair<int, int>p)
{
	vector<pair<int, int> >r;
	r.push_back(p);
	REP(i, h - 1)
	{
		p = ref_down[p.first][p.second];
		r.push_back(p);
	}
	return r;
}

vector<pair<int, int> > eval_right(vector<vector<pair<int, int>>>& ref_right, vector<vector<pair<int, int>>>& ref_down, int w, pair<int, int>p)
{
	vector<pair<int, int> >r;
	r.push_back(p);
	REP(i, w - 1)
	{
		p = ref_right[p.first][p.second];
		r.push_back(p);
	}
	return r;
}

// BEGIN CUT HERE
int main(int argc, char* argv[])
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif

	int n, m, q;
	cin >> n >> m >> q;

	VVI data(n, VI(m));
	REP(i, n)
		REP(j, m)
			cin >> data[i][j];

	vector<vector<pair<int,int>>> ref_down(n+2, vector<pair<int,int>> (m+2));
	vector<vector<pair<int, int>>> ref_right(n + 2, vector<pair<int, int>>(m + 2));

	REP(i, n + 2)
	{
		REP(j, m + 2)
		{
			ref_right[i][j] = MP(i, j + 1);
			ref_down[i][j] = MP(i + 1, j);
		}
	}

	REP(p, q)
	{
		int a, b, c, d, h, w;
		cin >> a >> b >> c >> d >> h >> w;
		--a;
		--b;
		--c;
		--d;

		{
			int start1row = a + 1;
			int start1col = b + 1;
			int end1row = a + h;
			int end1col = b + w;

			int start2row = c + 1;
			int start2col = d + 1;
			int end2row = c + h;
			int end2col = d + w;

			// in 1st -> in 2nd
			pair<int, int> o1 = go(ref_right, ref_down, start1row, start1col-1);
			vector<pair<int, int>> o1v = eval_down(ref_right, ref_down, h, o1);

			pair<int, int> l1 = go(ref_right, ref_down, start2row, start2col);
			vector<pair<int, int>> l1v = eval_down(ref_right, ref_down, h, l1);

			pair<int, int> o2 = go(ref_right, ref_down, start1row-1, start1col);
			vector<pair<int, int>> o2v = eval_right(ref_right, ref_down, w, o2);

			pair<int, int> l2 = go(ref_right, ref_down, start2row, start2col);
			vector<pair<int, int>> l2v = eval_right(ref_right, ref_down, w, l2);

			// in 2nd -> in 1st
			pair<int, int> o_1 = go(ref_right, ref_down, start2row, start2col - 1);
			vector<pair<int, int>> o_1v = eval_down(ref_right, ref_down, h, o_1);

			pair<int, int> l_1 = go(ref_right, ref_down, start1row, start1col);
			vector<pair<int, int>> l_1v = eval_down(ref_right, ref_down, h, l_1);

			pair<int, int> o_2 = go(ref_right, ref_down, start2row - 1, start2col);
			vector<pair<int, int>> o_2v = eval_right(ref_right, ref_down, w, o_2);

			pair<int, int> l_2 = go(ref_right, ref_down, start1row, start1col);
			vector<pair<int, int>> l_2v = eval_right(ref_right, ref_down, w, l_2);

			// out 1st -> out 2nd
			pair<int, int> o__1 = go(ref_right, ref_down, start1row, end1col);
			vector<pair<int, int>> o__1v = eval_down(ref_right, ref_down, h, o__1);
			pair<int, int> l__1 = go(ref_right, ref_down, start2row, end2col + 1);
			vector<pair<int, int>> l__1v = eval_down(ref_right, ref_down, h, l__1);

			pair<int, int> o__2 = go(ref_right, ref_down, end1row, start1col);
			vector<pair<int, int>> o__2v = eval_right(ref_right, ref_down, w, o__2);
			pair<int, int> l__2 = go(ref_right, ref_down, end2row+1, start2col);
			vector<pair<int, int>> l__2v = eval_right(ref_right, ref_down, w, l__2);

			// out 2nd -> out 1st
			pair<int, int> o___1 = go(ref_right, ref_down, start2row, end2col);
			vector<pair<int, int>> o___1v = eval_down(ref_right, ref_down, h, o___1);
			pair<int, int> l___1 = go(ref_right, ref_down, start1row, end1col + 1);
			vector<pair<int, int>> l___1v = eval_down(ref_right, ref_down, h, l___1);

			pair<int, int> o___2 = go(ref_right, ref_down, end2row, start2col);
			vector<pair<int, int>> o___2v = eval_right(ref_right, ref_down, w, o___2);
			pair<int, int> l___2 = go(ref_right, ref_down, end1row + 1, start1col);
			vector<pair<int, int>> l___2v = eval_right(ref_right, ref_down, w, l___2);

			change_stripes(ref_right, ref_down, h,w,o1v, l1v, o2v, l2v);
			change_stripes(ref_right, ref_down, h,w,o_1v, l_1v, o_2v, l_2v);

			change_stripes(ref_right, ref_down, h,w, o__1v, l__1v, o__2v, l__2v);
			change_stripes(ref_right, ref_down, h,w,o___1v, l___1v, o___2v, l___2v);

		}

	}

	REP(a, n)
	{
		int i = a+1, j = 0;
		int x = ref_right[i][j].first, y = ref_right[i][j].second;

		REP(b, m)
		{
			cout << data[x - 1][y - 1] << " ";
			move_right(ref_right, ref_down, x, y);
		}

		cout << endl;

	}

	return 0;
	cout << endl;
	REP(b, m)
	{
		int i = 0, j = b + 1;
		int x = ref_down[i][j].first, y = ref_down[i][j].second;

		REP(a, n)
		{
			cout << data[x - 1][y - 1] << " ";
			move_down(ref_right, ref_down, x, y);
		}

		cout << endl;

	}

}
// END CUT HERE


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define VT vector
typedef VT<int> VI;
typedef VT<VI> VVI;
typedef VT<string> VS;
typedef VT<double> VD;
typedef pair<int, int> PII;
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define MP make_pair
#define FS first
#define SC second
#define SZ size()

vector<vector<PII>> ref_right;
vector<vector<PII>> ref_down;

void move_right(int& a, int& b)
{
	pair<int, int> next = ref_right[a][b];
	int i = next.first;
	int j = next.second;

	a = i;
	b = j;
}

void move_down(int& a, int& b)
{
	pair<int, int> next = ref_down[a][b];
	int i = next.first;
	int j = next.second;

	a = i;
	b = j;
}

PII move_right(PII p)
{
	pair<int, int> next = ref_right[p.first][p.second];
	return next;
}

PII move_down(PII p)
{
	pair<int, int> next = ref_down[p.first][p.second];
	return next;
}

pair<int, int> go(PII p)
{
	int i = 0;
	int j = 0;

	REP(t, p.first)
		move_down(i, j);

	REP(t, p.second)
		move_right(i, j);

	return make_pair(i, j);
}

pair<int, int> go(int a, int b)
{
	int i = 0;
	int j = 0;

	REP(t, a)
		move_down(i, j);

	REP(t, b)
		move_right(i, j);

	return make_pair(i, j);
}

void change_stripes(int h, int w, vector<pair<int,int>>& o1, vector<pair<int, int>>& l1, vector<pair<int, int>>& o2, vector<pair<int, int>>& l2)
{

	for (int cnt = 0; cnt < h; ++cnt)
	{
		int i1 = o1[cnt].first, j1 = o1[cnt].second;
		int i2 = l1[cnt].first, j2 = l1[cnt].second;

		ref_right[i1][j1] = MP(i2, j2);
	}

	for (int cnt = 0; cnt < w; ++cnt)
	{
		int i1 = o2[cnt].first, j1 = o2[cnt].second;
		int i2 = l2[cnt].first, j2 = l2[cnt].second;
		ref_down[i1][j1] = MP(i2, j2);
	}

}

vector<pair<int, int> > eval_down(int h, pair<int, int>p)
{
	vector<pair<int, int> >r;
	r.push_back(p);
	REP(i, h - 1)
	{
		p = ref_down[p.first][p.second];
		r.push_back(p);
	}
	return r;
}

vector<pair<int, int> > eval_right(int w, pair<int, int>p)
{
	vector<pair<int, int> >r;
	r.push_back(p);
	REP(i, w - 1)
	{
		p = ref_right[p.first][p.second];
		r.push_back(p);
	}
	return r;
}

// BEGIN CUT HERE
int main(int argc, char* argv[])
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif

	int n, m, q;
	scanf("%d %d %d", &n, &m, &q);

	VVI data(n, VI(m));
	REP(i, n)
		REP(j, m)
			scanf("%d", &data[i][j]);

	ref_down.assign(n + 2, vector<pair<int,int>> (m + 2));
	ref_right.assign(n + 2, vector<pair<int, int>>(m + 2));

	REP(i, n + 2)
	{
		REP(j, m + 2)
		{
			ref_right[i][j] = MP(i, j + 1);
			ref_down[i][j] = MP(i + 1, j);
		}
	}

	REP(p, q)
	{
		int a, b, c, d, h, w;
		scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &h, &w);
		--a;
		--b;
		--c;
		--d;

		{
			int start1row = a + 1;
			int start1col = b + 1;
			int end1row = a + h;
			int end1col = b + w;

			int start2row = c + 1;
			int start2col = d + 1;
			int end2row = c + h;
			int end2col = d + w;

			PII pab = go(a, b);
			PII pcd = go(c, d);

			// in 1st -> in 2nd
			pair<int, int> o1 = go(move_down(pab));
			vector<pair<int, int>> o1v = eval_down(h, o1);

			pair<int, int> l1 = go(move_down(move_right(pcd)));
			vector<pair<int, int>> l1v = eval_down(h, l1);

			pair<int, int> o2 = go(move_right(pab));
			vector<pair<int, int>> o2v = eval_right(w, o2);

			pair<int, int> l2 = go(move_down(move_right(pcd)));
			vector<pair<int, int>> l2v = eval_right(w, l2);

			// in 2nd -> in 1st
			pair<int, int> o_1 = go(move_down(pcd));
			vector<pair<int, int>> o_1v = eval_down(h, o_1);

			pair<int, int> l_1 = go(move_down(move_right(pab)));
			vector<pair<int, int>> l_1v = eval_down(h, l_1);

			pair<int, int> o_2 = go(move_right(pcd));
			vector<pair<int, int>> o_2v = eval_right(w, o_2);

			pair<int, int> l_2 = go(move_down(move_right(pab)));
			vector<pair<int, int>> l_2v = eval_right(w, l_2);

			// out 1st -> out 2nd
			pair<int, int> o__1 = go(start1row, end1col);
			vector<pair<int, int>> o__1v = eval_down(h, o__1);
			pair<int, int> l__1 = go(start2row, end2col + 1);
			vector<pair<int, int>> l__1v = eval_down(h, l__1);

			pair<int, int> o__2 = go(end1row, start1col);
			vector<pair<int, int>> o__2v = eval_right(w, o__2);
			pair<int, int> l__2 = go(end2row+1, start2col);
			vector<pair<int, int>> l__2v = eval_right(w, l__2);

			// out 2nd -> out 1st
			pair<int, int> o___1 = go(start2row, end2col);
			vector<pair<int, int>> o___1v = eval_down(h, o___1);
			pair<int, int> l___1 = go(start1row, end1col + 1);
			vector<pair<int, int>> l___1v = eval_down(h, l___1);

			pair<int, int> o___2 = go(end2row, start2col);
			vector<pair<int, int>> o___2v = eval_right(w, o___2);
			pair<int, int> l___2 = go(end1row + 1, start1col);
			vector<pair<int, int>> l___2v = eval_right(w, l___2);

			change_stripes(h,w,o1v, l1v, o2v, l2v);
			change_stripes(h,w,o_1v, l_1v, o_2v, l_2v);

			change_stripes(h,w, o__1v, l__1v, o__2v, l__2v);
			change_stripes(h,w,o___1v, l___1v, o___2v, l___2v);

		}

	}

	REP(a, n)
	{
		int i = a+1, j = 0;
		int x = ref_right[i][j].first, y = ref_right[i][j].second;

		REP(b, m)
		{
			cout << data[x - 1][y - 1] << " ";
			move_right(x, y);
		}

		cout << endl;

	}

	return 0;
	cout << endl;
	REP(b, m)
	{
		int i = 0, j = b + 1;
		int x = ref_down[i][j].first, y = ref_down[i][j].second;

		REP(a, n)
		{
			printf("%d ", data[x - 1][y - 1]);
			move_down(x, y);
		}

		printf("\n");

	}

}
// END CUT HERE


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define VT vector
typedef VT<int> VI;
typedef VT<VI> VVI;
typedef VT<string> VS;
typedef VT<double> VD;
typedef pair<int, int> PII;
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define MP make_pair
#define FS first
#define SC second
#define SZ size()

PII ref_right[1002][1002];
PII ref_down[1002][1002];
int dt[1002][1002];

void move_right(int& a, int& b)
{
	pair<int, int> next = ref_right[a][b];
	int i = next.first;
	int j = next.second;

	a = i;
	b = j;
}

void move_down(int& a, int& b)
{
	pair<int, int> next = ref_down[a][b];
	int i = next.first;
	int j = next.second;

	a = i;
	b = j;
}

PII move_right(PII p)
{
	pair<int, int> next = ref_right[p.first][p.second];
	return next;
}

PII move_down(PII p)
{
	pair<int, int> next = ref_down[p.first][p.second];
	return next;
}

pair<int, int> go(PII p)
{
	int i = 0;
	int j = 0;

	REP(t, p.first)
		move_down(i, j);

	REP(t, p.second)
		move_right(i, j);

	return make_pair(i, j);
}

pair<int, int> go(int a, int b)
{
	int i = 0;
	int j = 0;

	REP(t, a)
		move_down(i, j);

	REP(t, b)
		move_right(i, j);

	return make_pair(i, j);
}

void change_stripes(int h, int w, vector<PII>& o1, vector<PII>& l1, vector<PII>& o2, vector<PII>& l2)
{

	for (int cnt = 0; cnt < h; ++cnt)
	{
		int i1 = o1[cnt].first, j1 = o1[cnt].second;
		int i2 = l1[cnt].first, j2 = l1[cnt].second;

		ref_right[i1][j1] = MP(i2, j2);
	}

	for (int cnt = 0; cnt < w; ++cnt)
	{
		int i1 = o2[cnt].first, j1 = o2[cnt].second;
		int i2 = l2[cnt].first, j2 = l2[cnt].second;
		ref_down[i1][j1] = MP(i2, j2);
	}

}

void eval_down(int h, pair<int, int>p, VT<PII>& r)
{
	r.push_back(p);
	REP(i, h - 1)
	{
		p = ref_down[p.first][p.second];
		r.push_back(p);
	}
}

void eval_right(int w, pair<int, int>p, VT<PII>& r)
{
	r.push_back(p);
	REP(i, w - 1)
	{
		p = ref_right[p.first][p.second];
		r.push_back(p);
	}
}

// BEGIN CUT HERE
int main(int argc, char* argv[])
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif

	int n, m, q;
	scanf("%d %d %d", &n, &m, &q);

	REP(i, n)
		REP(j, m)
		scanf("%d", &dt[i][j]);

	REP(i, n + 2)
	{
		REP(j, m + 2)
		{
			ref_right[i][j] = MP(i, j + 1);
			ref_down[i][j] = MP(i + 1, j);
		}
	}

	vector<pair<int, int>> o1v, o2v;
	vector<pair<int, int>> l1v, l2v;
	vector<pair<int, int>> o_1v, o_2v;
	vector<pair<int, int>> l_1v, l_2v;

	vector<pair<int, int>> o__1v, o__2v;
	vector<pair<int, int>> l__1v, l__2v;
	vector<pair<int, int>> o___1v, o___2v;
	vector<pair<int, int>> l___1v, l___2v;

	o1v.reserve(1000), o2v.reserve(1000);
	l1v.reserve(1000), l2v.reserve(1000);
	o_1v.reserve(1000), o_2v.reserve(1000);
	l_1v.reserve(1000), l_2v.reserve(1000);

	o__1v.reserve(1000), o__2v.reserve(1000);
	l__1v.reserve(1000), l__2v.reserve(1000);
	o___1v.reserve(1000), o___2v.reserve(1000);
	l___1v.reserve(1000), l___2v.reserve(1000);

	REP(p, q)
	{
		int a, b, c, d, h, w;
		scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &h, &w);
		--a;
		--b;
		--c;
		--d;

		int start1row = a + 1;
		int start1col = b + 1;
		int end1row = a + h;
		int end1col = b + w;

		int start2row = c + 1;
		int start2col = d + 1;
		int end2row = c + h;
		int end2col = d + w;

		PII pab = go(a, b);
		PII pcd = go(c, d);

		o1v.clear(), o2v.clear();
		l1v.clear(), l2v.clear();
		o_1v.clear(), o_2v.clear();
		l_1v.clear(), l_2v.clear();

		o__1v.clear(), o__2v.clear();
		l__1v.clear(), l__2v.clear();
		o___1v.clear(), o___2v.clear();
		l___1v.clear(), l___2v.clear();

		// in 1st -> in 2nd

		//start1row, start1col - 1
		pair<int, int> o1 = move_down(pab);
		//pair<int, int> o1 = go(start1row, start1col - 1);
		eval_down(h, o1, o1v);

		pair<int, int> l1 = move_down(move_right(pcd));
		//pair<int, int> l1 = go(start2row, start2col);
		eval_down(h, l1, l1v);

		pair<int, int> o2 = move_right(pab);
		eval_right(w, o2, o2v);

		pair<int, int> l2 = move_down(move_right(pcd));
		eval_right(w, l2, l2v);

		// in 2nd -> in 1st
		pair<int, int> o_1 = move_down(pcd);
		eval_down(h, o_1, o_1v);

		pair<int, int> l_1 = move_down(move_right(pab));
		eval_down(h, l_1, l_1v);

		pair<int, int> o_2 = move_right(pcd);
		eval_right(w, o_2, o_2v);

		pair<int, int> l_2 = move_down(move_right(pab));
		eval_right(w, l_2, l_2v);

		PII p_s1r_e1c = go(start1row, end1col);
		PII p_s2r_e2c = go(start2row, end2col);
		//		PII pcd = go(c, d);

		// out 1st -> out 2nd
		pair<int, int> o__1 = p_s1r_e1c;
		eval_down(h, o__1, o__1v);
		pair<int, int> l__1 = move_right(p_s2r_e2c);
		eval_down(h, l__1, l__1v);

		pair<int, int> o__2 = go(end1row, start1col);
		eval_right(w, o__2, o__2v);
		pair<int, int> l__2 = go(end2row + 1, start2col);
		eval_right(w, l__2, l__2v);

		// out 2nd -> out 1st
		pair<int, int> o___1 = p_s2r_e2c;
		eval_down(h, o___1, o___1v);
		pair<int, int> l___1 = move_right(p_s1r_e1c);
		eval_down(h, l___1, l___1v);

		pair<int, int> o___2 = go(end2row, start2col);
		eval_right(w, o___2, o___2v);
		pair<int, int> l___2 = go(end1row + 1, start1col);
		eval_right(w, l___2, l___2v);

		change_stripes(h, w, o1v, l1v, o2v, l2v);
		change_stripes(h, w, o_1v, l_1v, o_2v, l_2v);

		change_stripes(h, w, o__1v, l__1v, o__2v, l__2v);
		change_stripes(h, w, o___1v, l___1v, o___2v, l___2v);

	}

	REP(a, n)
	{
		int i = a + 1, j = 0;
		int x = ref_right[i][j].first, y = ref_right[i][j].second;

		REP(b, m)
		{
			printf("%d ", dt[x - 1][y - 1]);
			move_right(x, y);
		}

		printf("\n");

	}

	//return 0;
	//cout << endl;
	//REP(b, m)
	//{
	//	int i = 0, j = b + 1;
	//	int x = ref_down[i][j].first, y = ref_down[i][j].second;

	//	REP(a, n)
	//	{
	//		printf("%d ", data[x - 1][y - 1]);
	//		move_down(x, y);
	//	}

	//	printf("\n");

	//}

}
// END CUT HERE


#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std ;

struct Node{
	int data ;
	Node *right ;
	Node *down ;
} a[1005][1005] ;

int main()
{
	int n , m , q ;
	int ai , bi , ci , di , hi , wi ;
	int i , j ;
	Node *p ;
	Node *y , *x ,*u ,*v ;

	cin >> n >> m >> q ;

	for ( i = 1 ; i <= n ; i++ )
		for ( j = 1 ; j <= m ; j++)
			scanf("%d",&a[i][j].data) ;

	for ( i = 0 ; i <= n ; i++ ){
		for ( j = 0 ; j <= m ; j++ ){
			a[i][j].right = &a[i][j+1] ;
			a[i][j].down = &a[i+1][j] ;
		}
	}

	while (q--){
		x = &a[0][0] ;
		y = &a[0][0] ;

		cin >> ai >> bi >> ci >> di >> hi >> wi ;

		for ( i = 1 ; i < ai ; i++ )
			x = x->down ;
		for ( i = 1 ; i < bi ; i++ )
			x = x->right ;
		for ( i = 1 ; i < ci ; i++ )
			y = y->down ;
		for ( i = 1 ; i < di ; i++ )
			y = y->right ;

		u = x ;
		v = y ;

		for ( i = 1 ; i <= hi ; i++ ){
			u = u->down ;
			v = v->down ;
			swap(u->right,v->right) ;
		}

		for ( i = 1 ; i <= wi ; i++ ){
			x = x->right ;
			y = y->right ;
			swap(x->down,y->down) ;
		}

		for ( i = 1 ; i <= wi ; i++ ){
			u = u->right ;
			v = v->right ;
			swap(u->down,v->down) ;
		}

		for ( i = 1 ; i <= hi ; i++ ){
			x = x->down ;
			y = y->down ;
			swap(x->right,y->right) ;
		}

	}

	p = &a[0][0] ;

	for ( i = 1 ; i <= n ; i++ ){

		p = p -> down ;
		y = p ;
		for ( j = 1 ; j <= m ; j++ ){
			y = y -> right ;
			cout << y->data << " " ;

		}

			cout << endl  ;

	}
	return 0 ;
}


#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <set>
#include <utility>

#define FOR(i,n) SFOR(i,0,n)
#define SFOR(i,m,n) for(i=m;i<n;i++)
#define FORD(i,n) for(i=n-1;i>=0;i--)

using namespace std;

int AO[1100][1100];

pair<int, int> D[1100][1100], R[1100][1100];

pair<int, int> find(int x, int y) {
	pair<int, int> q = make_pair(0, 0);
	int i;
	FOR(i, x) q = D[q.first][q.second];
	FOR(i, y) q = R[q.first][q.second];
	return q;
}

void ChangeD(pair<int, int>& c1, pair<int, int>& c2, int h) {
	int i;
	FOR(i, h) {
		swap(R[c1.first][c1.second], R[c2.first][c2.second]);
		if (i == h-1) break;
		c1 = D[c1.first][c1.second];
		c2 = D[c2.first][c2.second];
	}
}

void ChangeR(pair<int, int>& c1, pair<int, int>& c2, int w) {
	int i;
	FOR(i, w) {
		swap(D[c1.first][c1.second], D[c2.first][c2.second]);
		if (i == w-1) break;
		c1 = R[c1.first][c1.second];
		c2 = R[c2.first][c2.second];
	}
}

int main() {
	int n,m,q,i,j,k,a,b,c,d,h,w;
	scanf("%d%d%d", &n, &m, &q);
	FOR(i,n) FOR(j,m) scanf("%d", &AO[i][j]);
	int qq = 0;
	FOR(i, n+1) FOR(j, m+1) R[i][j] = make_pair(i, j+1);
	FOR(i, n+1) FOR(j, m+1) D[i][j] = make_pair(i+1, j);
	//FOR(i, n+1) {
	//	FOR(j, m+1) printf("R:(%d,%d)   ", R[i][j].first, R[i][j].second); printf("\n");
	//	FOR(j, m+1) printf("D:(%d,%d)   ", D[i][j].first, D[i][j].second); printf("\n\n");
	//} printf("\n");
	FOR(qq,q) {
		scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &h, &w);
		pair<int, int> q1 = find(a, b-1);
		pair<int, int> q2 = find(c, d-1);
		pair<int, int> w1 = find(a-1, b);
		pair<int, int> w2 = find(c-1, d);
		ChangeD(q1, q2, h);
		//FOR(i, n+1) {
		//	FOR(j, m+1) printf("R:(%d,%d)   ", R[i][j].first, R[i][j].second); printf("\n");
		//	FOR(j, m+1) printf("D:(%d,%d)   ", D[i][j].first, D[i][j].second); printf("\n\n");
		//} printf("\n");
		ChangeR(w1, w2, w);
		//FOR(i, n+1) {
		//	FOR(j, m+1) printf("R:(%d,%d)   ", R[i][j].first, R[i][j].second); printf("\n");
		//	FOR(j, m+1) printf("D:(%d,%d)   ", D[i][j].first, D[i][j].second); printf("\n\n");
		//} printf("\n");
		w1 = D[w1.first][w1.second];
		w2 = D[w2.first][w2.second];
		ChangeD(w1, w2, h);
		//FOR(i, n+1) {
		//	FOR(j, m+1) printf("R:(%d,%d)   ", R[i][j].first, R[i][j].second); printf("\n");
		//	FOR(j, m+1) printf("D:(%d,%d)   ", D[i][j].first, D[i][j].second); printf("\n\n");
		//} printf("\n");
		q1 = R[q1.first][q1.second];
		q2 = R[q2.first][q2.second];
		ChangeR(q1, q2, w);
		//FOR(i, n+1) {
		//	FOR(j, m+1) printf("R:(%d,%d)   ", R[i][j].first, R[i][j].second); printf("\n");
		//	FOR(j, m+1) printf("D:(%d,%d)   ", D[i][j].first, D[i][j].second); printf("\n\n");
		//} printf("\n");
	}
	FOR(i, n) {
		pair<int, int> c1 = find(i+1, 0);
		FOR(j, m) { c1 = R[c1.first][c1.second]; printf("%d ", AO[c1.first-1][c1.second-1]); }
		printf("\n");
	}
}


#pragma comment(linker, "/stack:20000000")
#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <cstdio>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>

using namespace std;

// Let's define unordered map
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace std::tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"

#ifdef _MSC_VER
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#endif

#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << std::endl
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; std::cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<std::endl;

#define mp make_pair
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<typename T1, typename T2, typename T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>
template<typename T1, typename T2, typename T3>
bool operator<(const triple<T1, T2, T3> &t1, const triple<T1, T2, T3> &t2){ if (t1.a != t2.a) return t1.a<t2.a; else if (t1.b != t2.b) return t1.b<t2.b; else return t1.c < t2.c; }

#define FI(n) for(int i=0;i<n;++i)
#define FJ(n) for(int j=0;j<n;++j)
#define FK(n) for(int k=0;k<n;++k)
#define all(a) a.begin(), a.end()
//int some_primes[10] = {100271, 500179, 1000003, 2000227, 5000321}

inline int bits_count(int v){ v = v - ((v >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); return((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; }
inline int bits_count(ll v){ int t = v >> 32; int p = (v & ((1LL << 32) - 1)); return bits_count(t) + bits_count(p); }
unsigned int reverse_bits(register unsigned int x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
inline int sign(int x){ return x > 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
#define checkbit(n, b) ((n >> b) & 1)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

//STL output ********************************
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p);
template<typename T> inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v);
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v);
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v);
template<typename T1, typename T2, typename T3> inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t);
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p){ return os << "(" << p.first << ", " << p.second << ")"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v){ bool first = true; os << "["; for (unsigned int i = 0; i<v.size(); i++){ if (!first)os << ", "; os << v[i]; first = false; }return os << "]"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T, typename T2>void printarray(T  a[], T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }
template<typename T1, typename T2, typename T3>
inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }

//Pair magic
template<typename T1, typename T2> inline pair<T1, T2> operator+(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second); }
template<typename T1, typename T2> inline pair<T1, T2> operator-(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second); }

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

inline ll mulmod(ll x, ll n, ll _mod){ ll res = 0; while (n){ if (n & 1)res = (res + x) % _mod; x = (x + x) % _mod; n >>= 1; }return res; }
inline ll powmod(ll x, ll n, ll _mod){ ll res = 1; while (n){ if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; }return res; }
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline int gcd(int a, int b){ int t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline ll lcm(ll a, ll b){ return a / gcd(a, b)*b; }
inline ll gcd(ll a, ll b, ll c){ return gcd(gcd(a, b), c); }
inline int gcd(int a, int b, int c){ return gcd(gcd(a, b), c); }

// Useful constants

#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define mod         1000000007
#define PI          3.14159265358979323
#define link        asaxlajrewqwe
#define rank        wahayawehasdakw
//*************************************************************************************

const int BUSFIZE = 4096;
int read_int() {
    static char inbuf[BUSFIZE + 16];
    static char* inp = inbuf;
    static char* linp = inbuf + BUSFIZE;
    if (*inp == 0) {
        cin.read(inbuf, BUSFIZE);
        inp = inbuf;
    }
    while (*inp && (*inp < '0' || *inp > '9'))
        ++inp;
    int res = 0;
    while (*inp >= '0' && *inp <= '9') {
        res = res * 10 + *inp - '0';
        ++inp;
        if (inp == linp) {
            cin.read(inbuf, BUSFIZE);
            inp = inbuf;
        }
    }
    ++inp;
    return res;
}
static char outbuf[BUSFIZE + 16];
static char *outptr = outbuf;
static char *loutp = outbuf + BUSFIZE;
void write_int(int x) {
    char* begp = outptr;
    while (x) {
        int t = x / 10;
        char c = x - 10 * t + '0';
        *outptr++ = c;
        x = t;
    }
    char* endp = outptr - 1;
    while (begp < endp) {
        swap(*begp, *endp);
        ++begp;
        --endp;
    }
    if (outptr > loutp) {
        cout.write(outbuf, outptr - outbuf);
        outptr = outbuf;
    }
    *outptr++ = ' ';
}

int x[1008][1008];
void swap(char *a, char *b, int n) {
    int t = n % 64;
    if (t) {
        char buffer[64];
        memcpy(buffer, a, t);
        memcpy(a, b, t);
        memcpy(b, buffer, t);
        a += t;
        b += t;
    }
    n /= 64;
    typedef __m128i* Ptr;
    Ptr ptra = (Ptr)a;
    Ptr ptrb = (Ptr)b;
    char buffer[3008];
    auto buff = (Ptr) buffer;
    t = n;
    while (t--) {
        _mm_storeu_si128(buff + 0, _mm_loadu_si128(ptrb + 0));
        _mm_storeu_si128(buff + 1, _mm_loadu_si128(ptrb + 1));
        _mm_storeu_si128(buff + 2, _mm_loadu_si128(ptrb + 2));
        _mm_storeu_si128(buff + 3, _mm_loadu_si128(ptrb + 3));
        buff += 4;
        ptrb += 4;
    }
    t = n;
    ptrb = (Ptr)b;
    while (t--) {
        _mm_storeu_si128(ptrb + 0, _mm_loadu_si128(ptra + 0));
        _mm_storeu_si128(ptrb + 1, _mm_loadu_si128(ptra + 1));
        _mm_storeu_si128(ptrb + 2, _mm_loadu_si128(ptra + 2));
        _mm_storeu_si128(ptrb + 3, _mm_loadu_si128(ptra + 3));
        ptra += 4;
        ptrb += 4;
    }
    t = n;
    buff = (Ptr) buffer;
    ptra = (Ptr)a;
    while (t--) {
        _mm_storeu_si128(ptra + 0, _mm_loadu_si128(buff + 0));
        _mm_storeu_si128(ptra + 1, _mm_loadu_si128(buff + 1));
        _mm_storeu_si128(ptra + 2, _mm_loadu_si128(buff + 2));
        _mm_storeu_si128(ptra + 3, _mm_loadu_si128(buff + 3));
        ptra += 4;
        buff += 4;
    }
}
int v[1008 * 1008];
char data[1008][3008];
int vs = 0;

int main() {
#ifdef LOCAL
    FREIN("in.txt");
    FREOUT("out.txt");
#endif
    ios_base::sync_with_stdio(0);
    int n, m, q;
    n = read_int();
    m = read_int();
    q = read_int();
    FI(n) FJ(m) {
        v[vs] = read_int();
        int val = vs++;
        char *ptr = data[i] + j * 3;
        const char* valPtr = (const char*)&val;
        ptr[0] = valPtr[0];
        ptr[1] = valPtr[1];
        ptr[2] = valPtr[2];
    }
    while (q--) {
        int a, b, c, d, w, h;
        a = read_int();
        b = read_int();
        c = read_int();
        d = read_int();
        h = read_int();
        w = read_int();
        --a; --b; --c; --d;
        for (int i = 0; i < h; ++i) {
            swap(data[a + i] + b * 3, data[c + i] + d * 3, w * 3);
        }
    }
    FI(n) {
        FJ(m) {
            int val = 0;
            const char *ptr = data[i] + j * 3;
            char* valPtr = (char*)&val;
            valPtr[0] = ptr[0];
            valPtr[1] = ptr[1];
            valPtr[2] = ptr[2];
            val = v[val];
            write_int(val);
        }
        *outptr++ = '\n';
    }
    cout.write(outbuf, outptr - outbuf);
    CURTIME();
    return 0;
}


#pragma comment(linker, "/stack:20000000")
#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <cstdio>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>

using namespace std;

// Let's define unordered map
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace std::tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"

#ifdef _MSC_VER
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#endif

#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << std::endl
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; std::cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<std::endl;

#define mp make_pair
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<typename T1, typename T2, typename T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>
template<typename T1, typename T2, typename T3>
bool operator<(const triple<T1, T2, T3> &t1, const triple<T1, T2, T3> &t2){ if (t1.a != t2.a) return t1.a<t2.a; else if (t1.b != t2.b) return t1.b<t2.b; else return t1.c < t2.c; }

#define FI(n) for(int i=0;i<n;++i)
#define FJ(n) for(int j=0;j<n;++j)
#define FK(n) for(int k=0;k<n;++k)
#define all(a) a.begin(), a.end()
//int some_primes[10] = {100271, 500179, 1000003, 2000227, 5000321}

inline int bits_count(int v){ v = v - ((v >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); return((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; }
inline int bits_count(ll v){ int t = v >> 32; int p = (v & ((1LL << 32) - 1)); return bits_count(t) + bits_count(p); }
unsigned int reverse_bits(register unsigned int x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
inline int sign(int x){ return x > 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
#define checkbit(n, b) ((n >> b) & 1)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

//STL output ********************************
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p);
template<typename T> inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v);
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v);
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v);
template<typename T1, typename T2, typename T3> inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t);
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p){ return os << "(" << p.first << ", " << p.second << ")"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v){ bool first = true; os << "["; for (unsigned int i = 0; i<v.size(); i++){ if (!first)os << ", "; os << v[i]; first = false; }return os << "]"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T, typename T2>void printarray(T  a[], T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }
template<typename T1, typename T2, typename T3>
inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }

//Pair magic
template<typename T1, typename T2> inline pair<T1, T2> operator+(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second); }
template<typename T1, typename T2> inline pair<T1, T2> operator-(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second); }

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

inline ll mulmod(ll x, ll n, ll _mod){ ll res = 0; while (n){ if (n & 1)res = (res + x) % _mod; x = (x + x) % _mod; n >>= 1; }return res; }
inline ll powmod(ll x, ll n, ll _mod){ ll res = 1; while (n){ if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; }return res; }
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline int gcd(int a, int b){ int t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline ll lcm(ll a, ll b){ return a / gcd(a, b)*b; }
inline ll gcd(ll a, ll b, ll c){ return gcd(gcd(a, b), c); }
inline int gcd(int a, int b, int c){ return gcd(gcd(a, b), c); }

// Useful constants

#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define mod         1000000007
#define PI          3.14159265358979323
#define link        asaxlajrewqwe
#define rank        wahayawehasdakw
//*************************************************************************************

const int BUSFIZE = 4096;
int read_int() {
    static char inbuf[BUSFIZE + 16];
    static char* inp = inbuf;
    static char* linp = inbuf + BUSFIZE;
    if (*inp == 0) {
        cin.read(inbuf, BUSFIZE);
        inp = inbuf;
    }
    while (*inp && (*inp < '0' || *inp > '9'))
        ++inp;
    int res = 0;
    while (*inp >= '0' && *inp <= '9') {
        res = res * 10 + *inp - '0';
        ++inp;
        if (inp == linp) {
            cin.read(inbuf, BUSFIZE);
            inp = inbuf;
        }
    }
    ++inp;
    return res;
}
static char outbuf[BUSFIZE + 16];
static char *outptr = outbuf;
static char *loutp = outbuf + BUSFIZE;
void write_int(int x) {
    char* begp = outptr;
    while (x) {
        int t = x / 10;
        char c = x - 10 * t + '0';
        *outptr++ = c;
        x = t;
    }
    char* endp = outptr - 1;
    while (begp < endp) {
        swap(*begp, *endp);
        ++begp;
        --endp;
    }
    if (outptr > loutp) {
        cout.write(outbuf, outptr - outbuf);
        outptr = outbuf;
    }
    *outptr++ = ' ';
}

int x[1008][1008];
void swap(char *a, char *b, int n) {
    char buffer[3008];
    int t = n % 16;
    if (t) {
        memcpy(buffer, a, t);
        memcpy(a, b, t);
        memcpy(b, buffer, t);
        a += t;
        b += t;
    }
    n /= 16;
    using Ptr = __m128i*;
    Ptr ptra = (Ptr)a;
    Ptr ptrb = (Ptr)b;
    int o = n % 4;
    while (o--) {
        __m128i t = _mm_loadu_si128(ptra);
        _mm_storeu_si128(ptra, _mm_loadu_si128(ptrb));
        _mm_storeu_si128(ptrb, t);
        ++ptra;
        ++ptrb;
    }
    int n4 = n / 4;
    while (n4--) {
        __m128i t[4] = {_mm_loadu_si128(ptra), _mm_loadu_si128(ptra + 1), _mm_loadu_si128(ptra + 2), _mm_loadu_si128(ptra + 3)};
        _mm_storeu_si128(ptra + 0, _mm_loadu_si128(ptrb + 0));
        _mm_storeu_si128(ptra + 1, _mm_loadu_si128(ptrb + 1));
        _mm_storeu_si128(ptra + 2, _mm_loadu_si128(ptrb + 2));
        _mm_storeu_si128(ptra + 3, _mm_loadu_si128(ptrb + 3));
        _mm_storeu_si128(ptrb + 0, t[0]);
        _mm_storeu_si128(ptrb + 1, t[1]);
        _mm_storeu_si128(ptrb + 2, t[2]);
        _mm_storeu_si128(ptrb + 3, t[3]);
        ptra += 4;
        ptrb += 4;
    }
}
int v[1008 * 1008];
char data[1008][3008];
int vs = 0;

int main() {
#ifdef LOCAL
    FREIN("in.txt");
    FREOUT("out.txt");
#endif
    ios_base::sync_with_stdio(0);
    int n, m, q;
    n = read_int();
    m = read_int();
    q = read_int();
    FI(n) FJ(m) {
        v[vs] = read_int();
        int val = vs++;
        char *ptr = data[i] + j * 3;
        const char* valPtr = (const char*)&val;
        ptr[0] = valPtr[0];
        ptr[1] = valPtr[1];
        ptr[2] = valPtr[2];
    }
    while (q--) {
        int a, b, c, d, w, h;
        a = read_int();
        b = read_int();
        c = read_int();
        d = read_int();
        h = read_int();
        w = read_int();
        --a; --b; --c; --d;
        for (int i = 0; i < h; ++i) {
            swap(data[a + i] + b * 3, data[c + i] + d * 3, w * 3);
        }
    }
    FI(n) {
        FJ(m) {
            int val = 0;
            const char *ptr = data[i] + j * 3;
            char* valPtr = (char*)&val;
            valPtr[0] = ptr[0];
            valPtr[1] = ptr[1];
            valPtr[2] = ptr[2];
            val = v[val];
            write_int(val);
        }
        *outptr++ = '\n';
    }
    cout.write(outbuf, outptr - outbuf);
    CURTIME();
    return 0;
}


#pragma comment(linker, "/stack:20000000")
#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <cstdio>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>

using namespace std;

// Let's define unordered map
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace std::tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"

#ifdef _MSC_VER
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#endif

#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << std::endl
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; std::cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<std::endl;

#define mp make_pair
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<typename T1, typename T2, typename T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>
template<typename T1, typename T2, typename T3>
bool operator<(const triple<T1, T2, T3> &t1, const triple<T1, T2, T3> &t2){ if (t1.a != t2.a) return t1.a<t2.a; else if (t1.b != t2.b) return t1.b<t2.b; else return t1.c < t2.c; }

#define FI(n) for(int i=0;i<n;++i)
#define FJ(n) for(int j=0;j<n;++j)
#define FK(n) for(int k=0;k<n;++k)
#define all(a) a.begin(), a.end()
//int some_primes[10] = {100271, 500179, 1000003, 2000227, 5000321}

inline int bits_count(int v){ v = v - ((v >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); return((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; }
inline int bits_count(ll v){ int t = v >> 32; int p = (v & ((1LL << 32) - 1)); return bits_count(t) + bits_count(p); }
unsigned int reverse_bits(register unsigned int x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
inline int sign(int x){ return x > 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
#define checkbit(n, b) ((n >> b) & 1)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

//STL output ********************************
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p);
template<typename T> inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v);
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v);
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v);
template<typename T1, typename T2, typename T3> inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t);
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p){ return os << "(" << p.first << ", " << p.second << ")"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v){ bool first = true; os << "["; for (unsigned int i = 0; i<v.size(); i++){ if (!first)os << ", "; os << v[i]; first = false; }return os << "]"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T, typename T2>void printarray(T  a[], T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }
template<typename T1, typename T2, typename T3>
inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }

//Pair magic
template<typename T1, typename T2> inline pair<T1, T2> operator+(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second); }
template<typename T1, typename T2> inline pair<T1, T2> operator-(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second); }

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

inline ll mulmod(ll x, ll n, ll _mod){ ll res = 0; while (n){ if (n & 1)res = (res + x) % _mod; x = (x + x) % _mod; n >>= 1; }return res; }
inline ll powmod(ll x, ll n, ll _mod){ ll res = 1; while (n){ if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; }return res; }
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline int gcd(int a, int b){ int t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline ll lcm(ll a, ll b){ return a / gcd(a, b)*b; }
inline ll gcd(ll a, ll b, ll c){ return gcd(gcd(a, b), c); }
inline int gcd(int a, int b, int c){ return gcd(gcd(a, b), c); }

// Useful constants

#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define mod         1000000007
#define PI          3.14159265358979323
#define link        asaxlajrewqwe
#define rank        wahayawehasdakw
//*************************************************************************************

const int BUSFIZE = 4096;
int read_int() {
    static char inbuf[BUSFIZE + 16];
    static char* inp = inbuf;
    static char* linp = inbuf + BUSFIZE;
    if (*inp == 0) {
        cin.read(inbuf, BUSFIZE);
        inp = inbuf;
    }
    while (*inp && (*inp < '0' || *inp > '9'))
        ++inp;
    int res = 0;
    while (*inp >= '0' && *inp <= '9') {
        res = res * 10 + *inp - '0';
        ++inp;
        if (inp == linp) {
            cin.read(inbuf, BUSFIZE);
            inp = inbuf;
        }
    }
    ++inp;
    return res;
}
static char outbuf[BUSFIZE + 16];
static char *outptr = outbuf;
static char *loutp = outbuf + BUSFIZE;
void write_int(int x) {
    char* begp = outptr;
    while (x) {
        int t = x / 10;
        char c = x - 10 * t + '0';
        *outptr++ = c;
        x = t;
    }
    char* endp = outptr - 1;
    while (begp < endp) {
        swap(*begp, *endp);
        ++begp;
        --endp;
    }
    if (outptr > loutp) {
        cout.write(outbuf, outptr - outbuf);
        outptr = outbuf;
    }
    *outptr++ = ' ';
}

int x[1008][1008];
void swap(char *a, char *b, int n) {
    int t = n % 64;
    if (t) {
        char buffer[64];
        memcpy(buffer, a, t);
        memcpy(a, b, t);
        memcpy(b, buffer, t);
        a += t;
        b += t;
    }
    n /= 64;
    typedef __m128i* Ptr;
//    Ptr ptra = (Ptr)a;
//    Ptr ptrb = (Ptr)b;
    while (n--) {
        char buffer[64];
        memcpy(buffer, a, 64);
        memcpy(a, b, 64);
        memcpy(b, buffer, 64);
        a += 64;
        b += 64;
//        __m128i t0 = _mm_loadu_si128(ptra + 0);
//        __m128i t1 = _mm_loadu_si128(ptra + 1);
//        __m128i t2 = _mm_loadu_si128(ptra + 2);
//        __m128i t3 = _mm_loadu_si128(ptra + 3);
//        _mm_storeu_si128(ptra + 0, _mm_loadu_si128(ptrb + 0));
//        _mm_storeu_si128(ptra + 1, _mm_loadu_si128(ptrb + 1));
//        _mm_storeu_si128(ptra + 2, _mm_loadu_si128(ptrb + 2));
//        _mm_storeu_si128(ptra + 3, _mm_loadu_si128(ptrb + 3));
//        _mm_storeu_si128(ptrb + 0, t0);
//        _mm_storeu_si128(ptrb + 1, t1);
//        _mm_storeu_si128(ptrb + 2, t2);
//        _mm_storeu_si128(ptrb + 3, t3);
//        ptra += 4;
//        ptrb += 4;
    }
}
int v[1008 * 1008];
char data[1008][3008];
int vs = 0;

int main() {
#ifdef LOCAL
    FREIN("in.txt");
    FREOUT("out.txt");
#endif
    ios_base::sync_with_stdio(0);
    int n, m, q;
    n = read_int();
    m = read_int();
    q = read_int();
    FI(n) FJ(m) {
        v[vs] = read_int();
        int val = vs++;
        char *ptr = data[i] + j * 3;
        const char* valPtr = (const char*)&val;
        ptr[0] = valPtr[0];
        ptr[1] = valPtr[1];
        ptr[2] = valPtr[2];
    }
    while (q--) {
        int a, b, c, d, w, h;
        a = read_int();
        b = read_int();
        c = read_int();
        d = read_int();
        h = read_int();
        w = read_int();
        --a; --b; --c; --d;
        for (int i = 0; i < h; ++i) {
            swap(data[a + i] + b * 3, data[c + i] + d * 3, w * 3);
        }
    }
    FI(n) {
        FJ(m) {
            int val = 0;
            const char *ptr = data[i] + j * 3;
            char* valPtr = (char*)&val;
            valPtr[0] = ptr[0];
            valPtr[1] = ptr[1];
            valPtr[2] = ptr[2];
            val = v[val];
            write_int(val);
        }
        *outptr++ = '\n';
    }
    cout.write(outbuf, outptr - outbuf);
    CURTIME();
    return 0;
}


#pragma comment(linker, "/stack:20000000")
#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <cstdio>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>

using namespace std;

// Let's define unordered map
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace std::tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"

#ifdef _MSC_VER
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#endif

#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << std::endl
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; std::cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<std::endl;

#define mp make_pair
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<typename T1, typename T2, typename T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>
template<typename T1, typename T2, typename T3>
bool operator<(const triple<T1, T2, T3> &t1, const triple<T1, T2, T3> &t2){ if (t1.a != t2.a) return t1.a<t2.a; else if (t1.b != t2.b) return t1.b<t2.b; else return t1.c < t2.c; }

#define FI(n) for(int i=0;i<n;++i)
#define FJ(n) for(int j=0;j<n;++j)
#define FK(n) for(int k=0;k<n;++k)
#define all(a) a.begin(), a.end()
//int some_primes[10] = {100271, 500179, 1000003, 2000227, 5000321}

inline int bits_count(int v){ v = v - ((v >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); return((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; }
inline int bits_count(ll v){ int t = v >> 32; int p = (v & ((1LL << 32) - 1)); return bits_count(t) + bits_count(p); }
unsigned int reverse_bits(register unsigned int x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
inline int sign(int x){ return x > 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
#define checkbit(n, b) ((n >> b) & 1)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

//STL output ********************************
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p);
template<typename T> inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v);
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v);
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v);
template<typename T1, typename T2, typename T3> inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t);
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p){ return os << "(" << p.first << ", " << p.second << ")"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v){ bool first = true; os << "["; for (unsigned int i = 0; i<v.size(); i++){ if (!first)os << ", "; os << v[i]; first = false; }return os << "]"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T, typename T2>void printarray(T  a[], T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }
template<typename T1, typename T2, typename T3>
inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }

//Pair magic
template<typename T1, typename T2> inline pair<T1, T2> operator+(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second); }
template<typename T1, typename T2> inline pair<T1, T2> operator-(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second); }

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

inline ll mulmod(ll x, ll n, ll _mod){ ll res = 0; while (n){ if (n & 1)res = (res + x) % _mod; x = (x + x) % _mod; n >>= 1; }return res; }
inline ll powmod(ll x, ll n, ll _mod){ ll res = 1; while (n){ if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; }return res; }
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline int gcd(int a, int b){ int t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline ll lcm(ll a, ll b){ return a / gcd(a, b)*b; }
inline ll gcd(ll a, ll b, ll c){ return gcd(gcd(a, b), c); }
inline int gcd(int a, int b, int c){ return gcd(gcd(a, b), c); }

// Useful constants

#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define mod         1000000007
#define PI          3.14159265358979323
#define link        asaxlajrewqwe
#define rank        wahayawehasdakw
//*************************************************************************************

const int BUSFIZE = 4096;
int read_int() {
    static char inbuf[BUSFIZE + 16];
    static char* inp = inbuf;
    static char* linp = inbuf + BUSFIZE;
    if (*inp == 0) {
        cin.read(inbuf, BUSFIZE);
        inp = inbuf;
    }
    while (*inp && (*inp < '0' || *inp > '9'))
        ++inp;
    int res = 0;
    while (*inp >= '0' && *inp <= '9') {
        res = res * 10 + *inp - '0';
        ++inp;
        if (inp == linp) {
            cin.read(inbuf, BUSFIZE);
            inp = inbuf;
        }
    }
    ++inp;
    return res;
}
static char outbuf[BUSFIZE + 16];
static char *outptr = outbuf;
static char *loutp = outbuf + BUSFIZE;
void write_int(int x) {
    char* begp = outptr;
    while (x) {
        int t = x / 10;
        char c = x - 10 * t + '0';
        *outptr++ = c;
        x = t;
    }
    char* endp = outptr - 1;
    while (begp < endp) {
        swap(*begp, *endp);
        ++begp;
        --endp;
    }
    if (outptr > loutp) {
        cout.write(outbuf, outptr - outbuf);
        outptr = outbuf;
    }
    *outptr++ = ' ';
}

int x[1008][1008];
void swap(char *a, char *b, int n) {
    char buffer[3008];
    int t = n % 16;
    if (t) {
        memcpy(buffer, a, t);
        memcpy(a, b, t);
        memcpy(b, buffer, t);
        a += t;
        b += t;
    }
    n /= 16;

    typedef __m128i* Ptr;
    Ptr ptra = (Ptr)a;
    Ptr ptrb = (Ptr)b;
    int o = n % 4;
    while (o--) {
        __m128i t = _mm_loadu_si128(ptra);
        _mm_storeu_si128(ptra, _mm_loadu_si128(ptrb));
        _mm_storeu_si128(ptrb, t);
        ++ptra;
        ++ptrb;
    }
    int n4 = n / 4;
    while (n4--) {
        __m128i t0 = _mm_loadu_si128(ptra + 0);
        __m128i t1 = _mm_loadu_si128(ptra + 1);
        __m128i t2 = _mm_loadu_si128(ptra + 2);
        __m128i t3 = _mm_loadu_si128(ptra + 3);
        _mm_storeu_si128(ptra + 0, _mm_loadu_si128(ptrb + 0));
        _mm_storeu_si128(ptra + 1, _mm_loadu_si128(ptrb + 1));
        _mm_storeu_si128(ptra + 2, _mm_loadu_si128(ptrb + 2));
        _mm_storeu_si128(ptra + 3, _mm_loadu_si128(ptrb + 3));
        _mm_storeu_si128(ptrb + 0, t0);
        _mm_storeu_si128(ptrb + 1, t1);
        _mm_storeu_si128(ptrb + 2, t2);
        _mm_storeu_si128(ptrb + 3, t3);
        ptra += 4;
        ptrb += 4;
    }
}
int v[1008 * 1008];
char data[1008][3008];
int vs = 0;

int main() {
#ifdef LOCAL
    FREIN("in.txt");
    FREOUT("out.txt");
#endif
    ios_base::sync_with_stdio(0);
    int n, m, q;
    n = read_int();
    m = read_int();
    q = read_int();
    FI(n) FJ(m) {
        v[vs] = read_int();
        int val = vs++;
        char *ptr = data[i] + j * 3;
        const char* valPtr = (const char*)&val;
        ptr[0] = valPtr[0];
        ptr[1] = valPtr[1];
        ptr[2] = valPtr[2];
    }
    while (q--) {
        int a, b, c, d, w, h;
        a = read_int();
        b = read_int();
        c = read_int();
        d = read_int();
        h = read_int();
        w = read_int();
        --a; --b; --c; --d;
        for (int i = 0; i < h; ++i) {
            swap(data[a + i] + b * 3, data[c + i] + d * 3, w * 3);
        }
    }
    FI(n) {
        FJ(m) {
            int val = 0;
            const char *ptr = data[i] + j * 3;
            char* valPtr = (char*)&val;
            valPtr[0] = ptr[0];
            valPtr[1] = ptr[1];
            valPtr[2] = ptr[2];
            val = v[val];
            write_int(val);
        }
        *outptr++ = '\n';
    }
    cout.write(outbuf, outptr - outbuf);
    CURTIME();
    return 0;
}


#pragma comment(linker, "/stack:20000000")
#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <cstdio>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>

using namespace std;

// Let's define unordered map
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace std::tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"

#ifdef _MSC_VER
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#endif

#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << std::endl
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; std::cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<std::endl;

#define mp make_pair
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<typename T1, typename T2, typename T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>
template<typename T1, typename T2, typename T3>
bool operator<(const triple<T1, T2, T3> &t1, const triple<T1, T2, T3> &t2){ if (t1.a != t2.a) return t1.a<t2.a; else if (t1.b != t2.b) return t1.b<t2.b; else return t1.c < t2.c; }

#define FI(n) for(int i=0;i<n;++i)
#define FJ(n) for(int j=0;j<n;++j)
#define FK(n) for(int k=0;k<n;++k)
#define all(a) a.begin(), a.end()
//int some_primes[10] = {100271, 500179, 1000003, 2000227, 5000321}

inline int bits_count(int v){ v = v - ((v >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); return((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; }
inline int bits_count(ll v){ int t = v >> 32; int p = (v & ((1LL << 32) - 1)); return bits_count(t) + bits_count(p); }
unsigned int reverse_bits(register unsigned int x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
inline int sign(int x){ return x > 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
#define checkbit(n, b) ((n >> b) & 1)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

//STL output ********************************
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p);
template<typename T> inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v);
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v);
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v);
template<typename T1, typename T2, typename T3> inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t);
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p){ return os << "(" << p.first << ", " << p.second << ")"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v){ bool first = true; os << "["; for (unsigned int i = 0; i<v.size(); i++){ if (!first)os << ", "; os << v[i]; first = false; }return os << "]"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T, typename T2>void printarray(T  a[], T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }
template<typename T1, typename T2, typename T3>
inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }

//Pair magic
template<typename T1, typename T2> inline pair<T1, T2> operator+(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second); }
template<typename T1, typename T2> inline pair<T1, T2> operator-(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second); }

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

inline ll mulmod(ll x, ll n, ll _mod){ ll res = 0; while (n){ if (n & 1)res = (res + x) % _mod; x = (x + x) % _mod; n >>= 1; }return res; }
inline ll powmod(ll x, ll n, ll _mod){ ll res = 1; while (n){ if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; }return res; }
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline int gcd(int a, int b){ int t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline ll lcm(ll a, ll b){ return a / gcd(a, b)*b; }
inline ll gcd(ll a, ll b, ll c){ return gcd(gcd(a, b), c); }
inline int gcd(int a, int b, int c){ return gcd(gcd(a, b), c); }

// Useful constants

#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define mod         1000000007
#define PI          3.14159265358979323
#define link        asaxlajrewqwe
#define rank        wahayawehasdakw
//*************************************************************************************

const int BUSFIZE = 4096;
int read_int() {
    static char inbuf[BUSFIZE + 16];
    static char* inp = inbuf;
    static char* linp = inbuf + BUSFIZE;
    if (*inp == 0) {
        cin.read(inbuf, BUSFIZE);
        inp = inbuf;
    }
    while (*inp && (*inp < '0' || *inp > '9'))
        ++inp;
    int res = 0;
    while (*inp >= '0' && *inp <= '9') {
        res = res * 10 + *inp - '0';
        ++inp;
        if (inp == linp) {
            cin.read(inbuf, BUSFIZE);
            inp = inbuf;
        }
    }
    ++inp;
    return res;
}
static char outbuf[BUSFIZE + 16];
static char *outptr = outbuf;
static char *loutp = outbuf + BUSFIZE;
void write_int(int x) {
    char* begp = outptr;
    while (x) {
        int t = x / 10;
        char c = x - 10 * t + '0';
        *outptr++ = c;
        x = t;
    }
    char* endp = outptr - 1;
    while (begp < endp) {
        swap(*begp, *endp);
        ++begp;
        --endp;
    }
    if (outptr > loutp) {
        cout.write(outbuf, outptr - outbuf);
        outptr = outbuf;
    }
    *outptr++ = ' ';
}

int x[1008][1008];
void swap(char *a, char *b, int n) {
    char buffer[3008];
    int t = n % 16;
    if (t) {
        memcpy(buffer, a, t);
        memcpy(a, b, t);
        memcpy(b, buffer, t);
        a += t;
        b += t;
    }
    n /= 16;
    using Ptr = __m128i*;
    Ptr ptra = (Ptr)a;
    Ptr ptrb = (Ptr)b;
    while (n--) {
        __m128i t = _mm_loadu_si128(ptra);
        _mm_storeu_si128(ptra, _mm_loadu_si128(ptrb));
        _mm_storeu_si128(ptrb, t);
        ++ptra;
        ++ptrb;
    }
}
int v[1008 * 1008];
char data[1008][3008];
int vs = 0;

int main() {
    FREIN("in.txt");
    FREOUT("out.txt");
    ios_base::sync_with_stdio(0);
    int n, m, q;
    n = read_int();
    m = read_int();
    q = read_int();
    FI(n) FJ(m) {
        v[vs] = read_int();
        int val = vs++;
        char *ptr = data[i] + j * 3;
        const char* valPtr = (const char*)&val;
        ptr[0] = valPtr[0];
        ptr[1] = valPtr[1];
        ptr[2] = valPtr[2];
    }
    while (q--) {
        int a, b, c, d, w, h;
        a = read_int();
        b = read_int();
        c = read_int();
        d = read_int();
        h = read_int();
        w = read_int();
        --a; --b; --c; --d;
        for (int i = 0; i < h; ++i) {
            swap(data[a + i] + b * 3, data[c + i] + d * 3, w * 3);
        }
    }
    FI(n) {
        FJ(m) {
            int val = 0;
            const char *ptr = data[i] + j * 3;
            char* valPtr = (char*)&val;
            valPtr[0] = ptr[0];
            valPtr[1] = ptr[1];
            valPtr[2] = ptr[2];
            val = v[val];
            write_int(val);
        }
        *outptr++ = '\n';
    }
    cout.write(outbuf, outptr - outbuf);
    CURTIME();
    return 0;
}


#pragma comment(linker, "/stack:20000000")
#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <cstdio>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>

using namespace std;

// Let's define unordered map
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace std::tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"

#ifdef _MSC_VER
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#endif

#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << std::endl
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; std::cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<std::endl;

#define mp make_pair
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<typename T1, typename T2, typename T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>
template<typename T1, typename T2, typename T3>
bool operator<(const triple<T1, T2, T3> &t1, const triple<T1, T2, T3> &t2){ if (t1.a != t2.a) return t1.a<t2.a; else if (t1.b != t2.b) return t1.b<t2.b; else return t1.c < t2.c; }

#define FI(n) for(int i=0;i<n;++i)
#define FJ(n) for(int j=0;j<n;++j)
#define FK(n) for(int k=0;k<n;++k)
#define all(a) a.begin(), a.end()
//int some_primes[10] = {100271, 500179, 1000003, 2000227, 5000321}

inline int bits_count(int v){ v = v - ((v >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); return((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; }
inline int bits_count(ll v){ int t = v >> 32; int p = (v & ((1LL << 32) - 1)); return bits_count(t) + bits_count(p); }
unsigned int reverse_bits(register unsigned int x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
inline int sign(int x){ return x > 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
#define checkbit(n, b) ((n >> b) & 1)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

//STL output ********************************
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p);
template<typename T> inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v);
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v);
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v);
template<typename T1, typename T2, typename T3> inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t);
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p){ return os << "(" << p.first << ", " << p.second << ")"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v){ bool first = true; os << "["; for (unsigned int i = 0; i<v.size(); i++){ if (!first)os << ", "; os << v[i]; first = false; }return os << "]"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T, typename T2>void printarray(T  a[], T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }
template<typename T1, typename T2, typename T3>
inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }

//Pair magic
template<typename T1, typename T2> inline pair<T1, T2> operator+(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second); }
template<typename T1, typename T2> inline pair<T1, T2> operator-(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second); }

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

inline ll mulmod(ll x, ll n, ll _mod){ ll res = 0; while (n){ if (n & 1)res = (res + x) % _mod; x = (x + x) % _mod; n >>= 1; }return res; }
inline ll powmod(ll x, ll n, ll _mod){ ll res = 1; while (n){ if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; }return res; }
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline int gcd(int a, int b){ int t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline ll lcm(ll a, ll b){ return a / gcd(a, b)*b; }
inline ll gcd(ll a, ll b, ll c){ return gcd(gcd(a, b), c); }
inline int gcd(int a, int b, int c){ return gcd(gcd(a, b), c); }

// Useful constants

#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define mod         1000000007
#define PI          3.14159265358979323
#define link        asaxlajrewqwe
#define rank        wahayawehasdakw
//*************************************************************************************

const int BUSFIZE = 4096;
int read_int() {
    static char inbuf[BUSFIZE + 16];
    static char* inp = inbuf;
    static char* linp = inbuf + BUSFIZE;
    if (*inp == 0) {
        cin.read(inbuf, BUSFIZE);
        inp = inbuf;
    }
    while (*inp && (*inp < '0' || *inp > '9'))
        ++inp;
    int res = 0;
    while (*inp >= '0' && *inp <= '9') {
        res = res * 10 + *inp - '0';
        ++inp;
        if (inp == linp) {
            cin.read(inbuf, BUSFIZE);
            inp = inbuf;
        }
    }
    ++inp;
    return res;
}
static char outbuf[BUSFIZE + 16];
static char *outptr = outbuf;
static char *loutp = outbuf + BUSFIZE;
void write_int(int x) {
    char* begp = outptr;
    while (x) {
        int t = x / 10;
        char c = x - 10 * t + '0';
        *outptr++ = c;
        x = t;
    }
    char* endp = outptr - 1;
    while (begp < endp) {
        swap(*begp, *endp);
        ++begp;
        --endp;
    }
    if (outptr > loutp) {
        cout.write(outbuf, outptr - outbuf);
        outptr = outbuf;
    }
    *outptr++ = ' ';
}

int x[1008][1008];
void swap(char *a, char *b, int n) {
    int t = n % 64;
    if (t) {
        char buffer[64];
        memcpy(buffer, a, t);
        memcpy(a, b, t);
        memcpy(b, buffer, t);
        a += t;
        b += t;
    }
    n /= 64;
    typedef __m128i* Ptr;
    Ptr ptra = (Ptr)a;
    Ptr ptrb = (Ptr)b;
    while (n--) {
        register __m128i t0 = _mm_loadu_si128(ptra + 0);
        register __m128i t1 = _mm_loadu_si128(ptra + 1);
        register __m128i t2 = _mm_loadu_si128(ptra + 2);
        register __m128i t3 = _mm_loadu_si128(ptra + 3);
        register __m128i t4 = _mm_loadu_si128(ptrb + 0);
        _mm_storeu_si128(ptrb + 0, t0);
        t0 = _mm_loadu_si128(ptrb + 1);
        _mm_storeu_si128(ptrb + 1, t1);
        t1 = _mm_loadu_si128(ptrb + 2);
        _mm_storeu_si128(ptrb + 2, t2);
        t2 = _mm_loadu_si128(ptrb + 3);
        _mm_storeu_si128(ptrb + 3, t3);

        _mm_storeu_si128(ptra + 0, t4);
        _mm_storeu_si128(ptra + 1, t0);
        _mm_storeu_si128(ptra + 2, t1);
        _mm_storeu_si128(ptra + 3, t2);
        ptra += 4;
        ptrb += 4;
    }
}
int v[1008 * 1008];
char data[1008][3008];
int vs = 0;

int main() {
#ifdef LOCAL
    FREIN("in.txt");
    FREOUT("out.txt");
#endif
    ios_base::sync_with_stdio(0);
    int n, m, q;
    n = read_int();
    m = read_int();
    q = read_int();
    FI(n) FJ(m) {
        v[vs] = read_int();
        int val = vs++;
        char *ptr = data[i] + j * 3;
        const char* valPtr = (const char*)&val;
        ptr[0] = valPtr[0];
        ptr[1] = valPtr[1];
        ptr[2] = valPtr[2];
    }
    while (q--) {
        int a, b, c, d, w, h;
        a = read_int();
        b = read_int();
        c = read_int();
        d = read_int();
        h = read_int();
        w = read_int();
        --a; --b; --c; --d;
        for (int i = 0; i < h; ++i) {
            swap(data[a + i] + b * 3, data[c + i] + d * 3, w * 3);
        }
    }
    FI(n) {
        FJ(m) {
            int val = 0;
            const char *ptr = data[i] + j * 3;
            char* valPtr = (char*)&val;
            valPtr[0] = ptr[0];
            valPtr[1] = ptr[1];
            valPtr[2] = ptr[2];
            val = v[val];
            write_int(val);
        }
        *outptr++ = '\n';
    }
    cout.write(outbuf, outptr - outbuf);
    CURTIME();
    return 0;
}


#pragma comment(linker, "/stack:20000000")
#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <cstdio>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>

using namespace std;

// Let's define unordered map
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace std::tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cout<<#a<<"=["; printarray(a,n); cout<<"]\n"
#define DAR(a,n,s) cout<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cout<<"]\n"

#ifdef _MSC_VER
#define ALIGN(x) __declspec(align(x))
#else
#define ALIGN(x) __attribute__((aligned(x)))
#endif

#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << std::endl
double __begin;
#define DTIME(ccc) __begin = clock(); ccc; std::cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<std::endl;

#define mp make_pair
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<typename T1, typename T2, typename T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>
template<typename T1, typename T2, typename T3>
bool operator<(const triple<T1, T2, T3> &t1, const triple<T1, T2, T3> &t2){ if (t1.a != t2.a) return t1.a<t2.a; else if (t1.b != t2.b) return t1.b<t2.b; else return t1.c < t2.c; }

#define FI(n) for(int i=0;i<n;++i)
#define FJ(n) for(int j=0;j<n;++j)
#define FK(n) for(int k=0;k<n;++k)
#define all(a) a.begin(), a.end()
//int some_primes[10] = {100271, 500179, 1000003, 2000227, 5000321}

inline int bits_count(int v){ v = v - ((v >> 1) & 0x55555555); v = (v & 0x33333333) + ((v >> 2) & 0x33333333); return((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; }
inline int bits_count(ll v){ int t = v >> 32; int p = (v & ((1LL << 32) - 1)); return bits_count(t) + bits_count(p); }
unsigned int reverse_bits(register unsigned int x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
inline int sign(int x){ return x > 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
#define checkbit(n, b) ((n >> b) & 1)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

//STL output ********************************
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p);
template<typename T> inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v);
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v);
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v);
template<typename T1, typename T2, typename T3> inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t);
template<typename T1, typename T2> inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p){ return os << "(" << p.first << ", " << p.second << ")"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::vector<T>& v){ bool first = true; os << "["; for (unsigned int i = 0; i<v.size(); i++){ if (!first)os << ", "; os << v[i]; first = false; }return os << "]"; }
template<typename T>inline std::ostream &operator<<(std::ostream &os, const std::set<T>&v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T1, typename T2>inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v){ bool first = true; os << "["; for (auto ii = v.begin(); ii != v.end(); ++ii){ if (!first)os << ", "; os << *ii; first = false; }return os << "]"; }
template<typename T, typename T2>void printarray(T  a[], T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }
template<typename T1, typename T2, typename T3>
inline std::ostream& operator << (std::ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }

//Pair magic
template<typename T1, typename T2> inline pair<T1, T2> operator+(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second); }
template<typename T1, typename T2> inline pair<T1, T2> operator-(const pair<T1, T2> &p1 , const pair<T1, T2> &p2) { return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second); }

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

inline ll mulmod(ll x, ll n, ll _mod){ ll res = 0; while (n){ if (n & 1)res = (res + x) % _mod; x = (x + x) % _mod; n >>= 1; }return res; }
inline ll powmod(ll x, ll n, ll _mod){ ll res = 1; while (n){ if (n & 1)res = (res*x) % _mod; x = (x*x) % _mod; n >>= 1; }return res; }
inline ll gcd(ll a, ll b){ ll t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline int gcd(int a, int b){ int t; while (b){ a = a%b; t = a; a = b; b = t; }return a; }
inline ll lcm(ll a, ll b){ return a / gcd(a, b)*b; }
inline ll gcd(ll a, ll b, ll c){ return gcd(gcd(a, b), c); }
inline int gcd(int a, int b, int c){ return gcd(gcd(a, b), c); }

// Useful constants

#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define mod         1000000007
#define PI          3.14159265358979323
#define link        asaxlajrewqwe
#define rank        wahayawehasdakw
//*************************************************************************************

const int BUSFIZE = 4096;
void X_aligned_memcpy_sse2(void* dest, const void* src, const unsigned long size)
{

    __asm
    {
        mov esi, src;    //src pointer
        mov edi, dest;   //dest pointer

        mov ebx, size;   //ebx is our counter
        shr ebx, 7;      //divide by 128 (8 * 128bit registers)

    loop_copy:
        prefetchnta 128[ESI]; //SSE2 prefetch
        prefetchnta 160[ESI];
        prefetchnta 192[ESI];
        prefetchnta 224[ESI];

        movdqa xmm0, 0[ESI]; //move data from src to registers
        movdqa xmm1, 16[ESI];
        movdqa xmm2, 32[ESI];
        movdqa xmm3, 48[ESI];
        movdqa xmm4, 64[ESI];
        movdqa xmm5, 80[ESI];
        movdqa xmm6, 96[ESI];
        movdqa xmm7, 112[ESI];

        movntdq 0[EDI], xmm0; //move data from registers to dest
        movntdq 16[EDI], xmm1;
        movntdq 32[EDI], xmm2;
        movntdq 48[EDI], xmm3;
        movntdq 64[EDI], xmm4;
        movntdq 80[EDI], xmm5;
        movntdq 96[EDI], xmm6;
        movntdq 112[EDI], xmm7;

        add esi, 128;
        add edi, 128;
        dec ebx;

        jnz loop_copy; //loop please
    loop_copy_end:
    }
}

int read_int() {
    static char inbuf[BUSFIZE + 16];
    static char* inp = inbuf;
    static char* linp = inbuf + BUSFIZE;
    if (*inp == 0) {
        cin.read(inbuf, BUSFIZE);
        inp = inbuf;
    }
    while (*inp && (*inp < '0' || *inp > '9'))
        ++inp;
    int res = 0;
    while (*inp >= '0' && *inp <= '9') {
        res = res * 10 + *inp - '0';
        ++inp;
        if (inp == linp) {
            cin.read(inbuf, BUSFIZE);
            inp = inbuf;
        }
    }
    ++inp;
    return res;
}
static char outbuf[BUSFIZE + 16];
static char *outp = outbuf;
static char *loutp = outbuf + BUSFIZE;
void write_int(int x) {
    char* begp = outp;
    while (x) {
        int t = x / 10;
        char c = x - 10 * t + '0';
        *outp++ = c;
        x = t;
    }
    char* endp = outp - 1;
    while (begp < endp) {
        swap(*begp, *endp);
        ++begp;
        --endp;
    }
    if (outp > loutp) {
        cout.write(outbuf, outp - outbuf);
        outp = outbuf;
    }
    *outp++ = ' ';
}

int x[1008][1008];
void swap(char *a, char *b, int n) {
    char buffer[3008];
    X_aligned_memcpy_sse2(buffer, a, n);
    X_aligned_memcpy_sse2(a, b, n);
    X_aligned_memcpy_sse2(b, buffer, n);
}
int v[1008 * 1008];
char data[1008][3008];
int vs = 0;

int main() {
//    FREIN("in.txt");
//    FREOUT("out.txt");
    ios_base::sync_with_stdio(0);
    int n, m, q;
    n = read_int();
    m = read_int();
    q = read_int();
    FI(n) FJ(m) {
        v[vs] = read_int();
        int val = vs++;
        char *ptr = data[i] + j * 3;
        const char* valPtr = (const char*)&val;
        ptr[0] = valPtr[0];
        ptr[1] = valPtr[1];
        ptr[2] = valPtr[2];
    }
    while (q--) {
        int a, b, c, d, w, h;
        a = read_int();
        b = read_int();
        c = read_int();
        d = read_int();
        h = read_int();
        w = read_int();
        --a; --b; --c; --d;
        for (int i = 0; i < h; ++i) {
            swap(data[a + i] + b * 3, data[c + i] + d * 3, w * 3);
        }
    }
    FI(n) {
        FJ(m) {
            int val = 0;
            const char *ptr = data[i] + j * 3;
            char* valPtr = (char*)&val;
            valPtr[0] = ptr[0];
            valPtr[1] = ptr[1];
            valPtr[2] = ptr[2];
            val = v[val];
            write_int(val);
        }
        *outp++ = '\n';
    }
    cout.write(outbuf, outp - outbuf);
    CURTIME();
    return 0;
}