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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//Krzysztof Boryczka
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)(x).size())
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'
#define WATCH(x) cout<<(#x)<<" is "<<(x)<<ent

//END OF TEMPLATE

int n;
int t[30][30];
ii f1;

void mv(int a1, int b1, int a2, int b2){
	cout<<"M"<<sp<<a1<<sp<<b1<<sp<<a2<<sp<<b2<<ent;
}

void farmer(){
	cout<<"R FARMER"<<ent;
}

void endturn(){
	cout<<"="<<ent;
}

void baza(){
	FORD(i, f1.st, 1){
		mv(f1.st, f1.nd, f1.st-1, f1.nd);
		f1.st--;
	}
	FORD(i, f1.nd, 1){
		mv(f1.st, f1.nd, f1.st, f1.nd-1);
		f1.nd--;
	}
}

void solve(){
	farmer();
	f1={0, 0};
	while(true){
		while(t[f1.st][f1.nd]<=0){
			if(f1.st==n-1 && f1.nd==n-1){
				baza();
				endturn();
				cout<<"==="<<ent;
				return;
			}
			else if(f1.nd==n-1){
				FORD(i, n-1, 1){
					mv(f1.st, f1.nd, f1.st, f1.nd-1);
					f1.nd--;
				}
				mv(f1.st, f1.nd, f1.st+1, f1.nd);
				f1.st++;
			}
			else{
				mv(f1.st, f1.nd, f1.st, f1.nd+1);
				f1.nd++;
			}
		}
		t[f1.st][f1.nd]-=10;
		endturn();
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int te;
	cin>>te;
	FOR(tt, 1, te){
		cin>>n;
		FOR(i, 0, n-1){
			FOR(j, 0, n-1){
				cin>>t[i][j];
			}
		}
		solve();
	}
	return 0;
}