1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
vector<pii> adir = {{2, 1},{3, 1},{4, 1},{5, 1},{6, 1},{7, 1},{8, 1},{9, 1},{10, 1},{11, 1},{12, 1},{13, 1},{14, 1},{15, 1},{16, 1},{17, 1},{18, 1},{19, 1},{20, 1},{20, 2},{20, 3},{20, 4},{20, 5},{20, 6},{20, 7},{20, 8},{20, 9},{20, 10},{20, 11},{20, 12},{20, 13},{20, 14},{20, 15},{20, 16},{20, 17},{20, 18},{20, 19},{20, 20},{19, 20},{19, 19},{19, 18},{19, 17},{19, 16},{19, 15},{19, 14},{19, 13},{19, 12},{19, 11},{19, 10},{19, 9},{19, 8},{19, 7},{19, 6},{19, 5},{19, 4},{19, 3},{19, 2},{18, 2},{18, 3},{18, 4},{18, 5},{18, 6},{18, 7},{18, 8},{18, 9},{18, 10},{18, 11},{18, 12},{18, 13},{18, 14},{18, 15},{18, 16},{18, 17},{18, 18},{18, 19},{18, 20},{17, 20},{17, 19},{17, 18},{17, 17},{17, 16},{17, 15},{17, 14},{17, 13},{17, 12},{17, 11},{17, 10},{17, 9},{17, 8},{17, 7},{17, 6},{17, 5},{17, 4},{17, 3},{17, 2},{16, 2},{16, 3},{16, 4},{16, 5},{16, 6},{16, 7},{16, 8},{16, 9},{16, 10},{16, 11},{16, 12},{16, 13},{16, 14},{16, 15},{16, 16},{16, 17},{16, 18},{16, 19},{16, 20},{15, 20},{15, 19},{15, 18},{15, 17},{15, 16},{15, 15},{15, 14},{15, 13},{15, 12},{15, 11},{15, 10},{15, 9},{15, 8},{15, 7},{15, 6},{15, 5},{15, 4},{15, 3},{15, 2},{14, 2},{14, 3},{14, 4},{14, 5},{14, 6},{14, 7},{14, 8},{14, 9},{14, 10},{14, 11},{14, 12},{14, 13},{14, 14},{14, 15},{14, 16},{14, 17},{14, 18},{14, 19},{14, 20},{13, 20},{13, 19},{13, 18},{13, 17},{13, 16},{13, 15},{13, 14},{13, 13},{13, 12},{13, 11},{13, 10},{13, 9},{13, 8},{13, 7},{13, 6},{13, 5},{13, 4},{13, 3},{13, 2},{12, 2},{12, 3},{12, 4},{12, 5},{12, 6},{12, 7},{12, 8},{12, 9},{12, 10},{12, 11},{12, 12},{12, 13},{12, 14},{12, 15},{12, 16},{12, 17},{12, 18},{12, 19},{12, 20},{11, 20},{11, 19},{11, 18},{11, 17},{11, 16},{11, 15},{11, 14},{11, 13},{11, 12},{11, 11},{11, 10},{11, 9},{11, 8},{11, 7},{11, 6},{11, 5},{11, 4},{11, 3},{11, 2},{10, 2},{9, 2},{8, 2},{7, 2},{6, 2},{5, 2},{4, 2},{3, 2},{2, 2},{2, 1},{1, 1},{2, 1}};
vector<pii> bdir = {{1, 2},{1, 3},{1, 4},{1, 5},{1, 6},{1, 7},{1, 8},{1, 9},{1, 10},{1, 11},{1, 12},{1, 13},{1, 14},{1, 15},{1, 16},{1, 17},{1, 18},{1, 19},{1, 20},{2, 20},{3, 20},{4, 20},{5, 20},{6, 20},{7, 20},{8, 20},{9, 20},{10, 20},{10, 19},{10, 18},{10, 17},{10, 16},{10, 15},{10, 14},{10, 13},{10, 12},{10, 11},{10, 10},{10, 9},{10, 8},{10, 7},{10, 6},{10, 5},{10, 4},{10, 3},{9, 3},{8, 3},{7, 3},{6, 3},{5, 3},{4, 3},{3, 3},{3, 4},{4, 4},{5, 4},{6, 4},{7, 4},{8, 4},{9, 4},{9, 5},{9, 6},{9, 7},{9, 8},{9, 9},{9, 10},{9, 11},{9, 12},{9, 13},{9, 14},{9, 15},{9, 16},{9, 17},{9, 18},{9, 19},{8, 19},{8, 18},{8, 17},{8, 16},{8, 15},{8, 14},{8, 13},{8, 12},{8, 11},{8, 10},{8, 9},{8, 8},{8, 7},{8, 6},{8, 5},{7, 5},{7, 6},{7, 7},{7, 8},{7, 9},{7, 10},{7, 11},{7, 12},{7, 13},{7, 14},{7, 15},{7, 16},{7, 17},{7, 18},{7, 19},{6, 19},{6, 18},{6, 17},{6, 16},{6, 15},{6, 14},{6, 13},{6, 12},{6, 11},{6, 10},{6, 9},{6, 8},{6, 7},{6, 6},{6, 5},{5, 5},{5, 6},{5, 7},{5, 8},{5, 9},{5, 10},{5, 11},{5, 12},{5, 13},{5, 14},{5, 15},{5, 16},{5, 17},{5, 18},{5, 19},{4, 19},{4, 18},{4, 17},{4, 16},{4, 15},{4, 14},{4, 13},{4, 12},{4, 11},{4, 10},{4, 9},{4, 8},{4, 7},{4, 6},{4, 5},{3, 5},{3, 6},{3, 7},{3, 8},{3, 9},{3, 10},{3, 11},{3, 12},{3, 13},{3, 14},{3, 15},{3, 16},{3, 17},{3, 18},{3, 19},{2, 19},{2, 18},{2, 17},{2, 16},{2, 15},{2, 14},{2, 13},{2, 12},{2, 11},{2, 10},{2, 9},{2, 8},{2, 7},{2, 6},{2, 5},{2, 4},{2, 3},{1, 3},{1, 2},{1, 1},{1, 2}};
int posa, posb, golda, goldb, n, k, delivered, q, rerer, gold[25][25];
void rusz(pii a, pii b)
{	cout << "M " << a.first - 1 << " " << a.second -1 << " " << b.first -1 << " " << b.second - 1 << "\n";
}
int main()
{	ios_base::sync_with_stdio(0);
	cin >> q >> k;
	while(q--)
	{	cin >> n >> rerer;
		posa = posb = 0;
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				cin >> gold[i][j];
		cout << "R FARMER\n";
		cout << "M 0 0 0 1\n";
		cout << "R FARMER\n";
		cout << "M 0 0 1 0\n";
		while(posa < adir.size() - 1 || posb < bdir.size() - 1)
		{	if(posa < adir.size() - 1)
			{	int x = adir[posa].first, y = adir[posa].second;
				if(gold[x][y] > 0)
				{	gold[x][y] -= 10;
				}
				else if(adir[posa + 1] == bdir[posb])// nie wlaz w kolege z laski swojej 
				{	gold[x][y] -= 10;
					// nic tu nie ma bo nic nie robie
				}
				else 
				{	rusz(adir[posa], adir[posa + 1]);
					posa++;
					x = adir[posa].first, y = adir[posa].second;
					gold[x][y] -= 10;
				}
			}
			if(posb < bdir.size() - 1)
			{	int x = bdir[posb].first, y = bdir[posb].second;
				if(gold[x][y] > 0)
				{	gold[x][y] -= 10;
				}
				else if(bdir[posb + 1] == adir[posa])// nie wlaz w kolege z laski swojej 
				{	gold[x][y] -= 10;
					// nic tu nie ma bo nic nie robie
				}
				else 
				{	rusz(bdir[posb], bdir[posb + 1]);
					posb++;
					x = bdir[posb].first, y = bdir[posb].second;
					gold[x][y] -= 10;
				}
			}
			cout << "=\n";
		}
	}
	cout << "===\n";
	
}