#include <bits/stdc++.h>   using namespace std;   int T, n, m, nw, a[110][110], id[110][110], pos[110], p[110];   char ch;   bool cmp(int i, int j) { return a[m][i] < a[m][j]; }   queue<int> q;   void find(int x) {     p[x] = 0;     int y = id[x][pos[x]];     pos[x]--;     if (!p[y])       p[y] = x, p[x] = y;     else if (a[y][x] > a[y][p[y]]) {       p[p[y]] = 0, q.push(p[y]);       p[y] = x, p[x] = y;     }     if (!p[x]) q.push(x);   }   void work() {     for (int i = 1; i <= 2 * n; i++) {       for (int j = 1; j <= n; j++) id[i][j] = (i <= n) * n + j;       m = i;       sort(id[i] + 1, id[i] + n + 1, cmp);       p[i] = 0;     }     for (int i = 1; i <= n; i++) pos[i] = n, q.push(i);     while (!q.empty()) {       int u = q.front();       q.pop();       find(u);     }     for (int i = 1; i <= n; i++) assert(p[i]);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         assert(!(a[p[i]][i] < a[p[i]][j] && a[j][p[i]] > a[j][p[j]]));   }   void solve() {     bool falg = 0;     scanf( %d , &n);     memset(a, 0, sizeof(a)), memset(id, 0, sizeof(id));     for (int i = 1; i <= n; i++)       for (int j = n + 1; j <= 2 * n; j++)         scanf( %d , &a[i][j]), a[j][i] = -a[i][j];     puts( B ), fflush(stdout);     scanf(  %c%d , &ch, &nw);     if (ch ==  I ) falg ^= 1;     if (nw > n) falg ^= 1;     if (falg)       for (int i = 1; i <= 2 * n; i++)         for (int j = 1; j <= 2 * n; j++) a[i][j] = -a[i][j];     work();     printf( %d n , p[nw]), fflush(stdout);     while (~scanf( %d , &nw)) {       if (nw == -1) return;       printf( %d n , p[nw]), fflush(stdout);     }   }   int main() {     scanf( %d , &T);     while (T--) solve();   }   