#include <bits/stdc++.h>
using namespace std;
char ch;
bool ask(int i, int j) {
  i++;
  j++;
  cout << "? " << i << " " << j << endl;
  fflush(stdout);
  cin >> ch;
  return ch == '<';
}
vector<int> lf;
vector<int> ri;
bool bo[1024];
int N;
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> N;
    lf.clear();
    ri.clear();
    memset(bo, 0, sizeof(bo));
    for (int i = 0; i < N; i++) {
      int a = 2 * i;
      int b = 2 * i + 1;
      if (ask(a, b)) {
        lf.push_back(a);
        ri.push_back(b);
      } else {
        lf.push_back(b);
        ri.push_back(a);
      }
    }
    sort(lf.begin(), lf.end(), ask);
    ri.erase(find(ri.begin(), ri.end(), lf[N - 1] ^ 1));
    sort(ri.begin(), ri.end(), ask);
    int pos1 = 0, pos2 = 0;
    for (int kkk = 0; kkk < N; kkk++) {
      if (!bo[ri[pos2]]) {
        bo[lf[pos1] ^ 1] = true;
        pos1++;
      } else {
        if (ask(lf[pos1], ri[pos2])) {
          bo[lf[pos1] ^ 1] = true;
          pos1++;
        } else {
          pos2++;
        }
      }
    }
    cout << "!" << endl;
    fflush(stdout);
  }
}
