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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <bits/stdc++.h>

#define pb push_back
#define st first
#define nd second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vld;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;

const int INF = 1e9 + 5;
const ll LINF = 1e18 + 5;
const int MOD7 = 1e9 + 7;
const int MOD9 = 1e9 +9;
const int N = 20;
const int M = 1e6 + 5;

struct pole{
    int w, x, y;
};

bool cmp(pole a, pole b){
    return a.w > b.w;
}

pole tab[N * N + 25];
vpi workers;
ll hajs = 200;

void clean(){
    workers.clear();
}

void kupfarmer(){
    cout << "R FARMER\n";
    workers.pb(mp(0, 0));
    hajs -= 100;
}

void solve(){
    int skaly = 0, zloto = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> tab[i * N + j].w;
            if(tab[i * N + j].w > 0){zloto++;}
            else {skaly++;} 
            tab[i * N + j].x = i; 
            tab[i * N + j].y = j;
        }
    }

    sort(tab, tab + N*N, cmp);
    
    int pole = 0;
    kupfarmer();
    kupfarmer();
    
    // for(int i = 0; i < N; i++){
    //     cout << tab[i].w << " " << tab[i].x << " " << tab[i].y << "\n";
    // }

    int x = 0;

    while(zloto > 0){
        //cout << "RUCHANIE\n";
        if(hajs >= 100){
            for(int i = 0; i < workers.size(); i++){
                cout << "M " << workers[i].st << " " << workers[i].nd << " 0 0\n";
                workers[i] = mp(0,0);
            }
            cout << "=\n";
            kupfarmer();
        } else {
            for(int i = 0; i < workers.size() && zloto > 0; i++){
                if(tab[pole].w > 0){
                    cout << "M 0 0 " << tab[pole].x << " " << tab[pole].y << "\n";
                    if(tab[pole].w > 10){
                        tab[pole].w -= 10;
                        hajs += 10;
                    } else {
                        //cout << "POLEWYZEROWANE\n";
                        hajs += tab[pole].w;
                        tab[pole].w = 0;
                        zloto--;
                        pole++;
                    }
                    workers[i] = mp(tab[pole].x,tab[pole].y);
                } else {
                    pole++;
                    i--;
                }
            }
            cout << "=\n";
        }
        x++;
    }

    cout << "===\n";
    
    

    clean();
}

int main(){
    //ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int T, k;
    cin >> T >> k;
    for(int i = 0; i < T; i++){solve();}
    return 0;
}