#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;

	}

	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(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);

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

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

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

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

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

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

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

			pair<int, int> l_2 = go(start1row, start1col);
			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()

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<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);

	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);
		}
	}

	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(0), l2v.reserve(1000);
	o_1v.reserve(0), o_2v.reserve(1000);
	l_1v.reserve(0), 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.resize(0), o2v.resize(0);
		l1v.resize(0), l2v.resize(0);
		o_1v.resize(0), o_2v.resize(0);
		l_1v.resize(0), l_2v.resize(0);

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

		// 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 pab = go(a, b);
//		PII pcd = go(c, d);

		// out 1st -> out 2nd
		pair<int, int> o__1 = go(start1row, end1col);
		eval_down(h, o__1, o__1v);
		pair<int, int> l__1 = go(start2row, end2col + 1);
		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 = go(start2row, end2col);
		eval_down(h, o___1, o___1v);
		pair<int, int> l___1 = go(start1row, end1col + 1);
		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)
		{
			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()

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(start1row, start1col-1);
			vector<pair<int, int>> o1v = eval_down(h, o1);

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

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

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

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

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

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

			pair<int, int> l_2 = go(start1row, start1col);
			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()

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(start2row, start2col);
			vector<pair<int, int>> l1v = eval_down(h, l1);

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

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

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

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

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

			pair<int, int> l_2 = go(start1row, start1col);
			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()

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

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

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

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

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

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

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

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

			pair<int, int> l_2 = go(start1row, start1col);
			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()

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<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);

	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);
		}
	}

	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(0), l2v.reserve(1000);
	o_1v.reserve(0), o_2v.reserve(1000);
	l_1v.reserve(0), 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.resize(0), o2v.resize(0);
		l1v.resize(0), l2v.resize(0);
		o_1v.resize(0), o_2v.resize(0);
		l_1v.resize(0), l_2v.resize(0);

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

		// 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 ", data[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 <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<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);

	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);
		}
	}

	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(0), l2v.reserve(1000);
	o_1v.reserve(0), o_2v.reserve(1000);
	l_1v.reserve(0), 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.resize(0), o2v.resize(0);
		l1v.resize(0), l2v.resize(0);
		o_1v.resize(0), o_2v.resize(0);
		l_1v.resize(0), l_2v.resize(0);

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

		// 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 pab = go(a, b);
//		PII pcd = go(c, d);

		// out 1st -> out 2nd
		pair<int, int> o__1 = go(start1row, end1col);
		eval_down(h, o__1, o__1v);
		pair<int, int> l__1 = go(start2row, end2col + 1);
		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 = go(start2row, end2col);
		eval_down(h, o___1, o___1v);
		pair<int, int> l___1 = go(start1row, end1col + 1);
		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 ", data[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 <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);
	}

}

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);

	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);
		}
	}

	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;

	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.resize(0), o2v.resize(0);
			l1v.resize(0), l2v.resize(0);
			o_1v.resize(0), o_2v.resize(0);
			l_1v.resize(0), l_2v.resize(0);

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

			// 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);

			// out 1st -> out 2nd
			pair<int, int> o__1 = go(start1row, end1col);
			eval_down(h, o__1, o__1v);
			pair<int, int> l__1 = go(start2row, end2col + 1);
			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 = go(start2row, end2col);
			eval_down(h, o___1, o___1v);
			pair<int, int> l___1 = go(start1row, end1col + 1);
			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)
		{
			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()

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

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

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

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

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

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

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

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

			pair<int, int> l_2 = 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()

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

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

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

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

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

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

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

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

			pair<int, int> l_2 = go(start1row, start1col);
			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()

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(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);

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

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

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

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

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

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

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

			pair<int, int> l_2 = go(start1row, start1col);
			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(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)
		{
			printf("%d ", data[x - 1][y - 1]);
			move_down(ref_right, ref_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()

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

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

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

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

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

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

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

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

			pair<int, int> l_2 = go(start1row, start1col);
			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()

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(start1row-1, start1col);
			vector<pair<int, int>> o2v = eval_right(w, o2);

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

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

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

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

			pair<int, int> l_2 = go(start1row, start1col);
			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()

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<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);

	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);
		}
	}

	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 ", data[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 <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()

pair<short, short> ref_right[1002][1002];
pair<short, short> 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 <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;
	scanf("%d %d %d", &n, &m, &q);

	VVI data(n, VI(m));
	REP(i, n)
		REP(j, m)
			scanf("%d", &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;
		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;

			// 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)
		{
			printf("%d ", data[x - 1][y - 1]);
			move_down(ref_right, ref_down, x, y);
		}

		printf("\n");

	}

}
// END CUT HERE