#include <bits/stdc++.h>
using namespace std;
;
const int N = 205;
inline int change(int x) { return x - 1 + ((x & 1) << 1); }
int T, n;
bool vis[N][N];
bool res[N][N];
int query(int x, int y) {
  static char s[5];
  if (vis[x][y]) return res[x][y];
  vis[x][y] = true;
  printf("? %d %d\n", x, y);
  fflush(stdout);
  scanf("%s", s);
  return res[x][y] = (s[0] == '>');
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    memset(vis, false, sizeof(vis));
    memset(res, false, sizeof(res));
    int n2 = n << 1;
    vector<int> P, Q;
    for (int i = 1; i <= n2; i += 2) {
      if (query(i, i + 1)) {
        Q.push_back(i);
        P.push_back(i + 1);
      } else {
        P.push_back(i);
        Q.push_back(i + 1);
      }
    }
    sort(P.begin(), P.end(), [&](int x, int y) { return query(x, y); });
    Q.erase(find(Q.begin(), Q.end(), change(P[0])));
    sort(Q.begin(), Q.end(), [&](int x, int y) { return query(x, y); });
    for (int i = 0; i < n - 1; i++) {
      if (!query(P[i], Q.back())) {
        break;
      }
      Q.pop_back();
    }
    puts("!");
    fflush(stdout);
  }
  return 0;
}
