#include <bits/stdc++.h>
using namespace std;
int T, n, a[205][3], b[205];
char op[2];
int ans;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      a[i][1] = i, a[i][2] = i + n;
      printf("? %d %d\n", i, i + n);
      fflush(stdout);
      scanf("%s", op);
      if (op[0] == '>') swap(a[i][1], a[i][2]);
    }
    for (int i = 1; i <= n; i++) b[i] = 1;
    int res = -1;
    for (int o = 1; o <= n; o++) {
      int now = -1;
      for (int i = 1; i <= n; i++)
        if (b[i] == 1) {
          if (now == -1)
            now = i;
          else {
            printf("? %d %d\n", a[now][1], a[i][1]);
            fflush(stdout);
            scanf("%s", op);
            if (op[0] == '>') now = i;
          }
        }
      if (o == n && n % 2 == 0) {
        printf("? %d %d\n", res, a[now][1]);
        fflush(stdout);
        scanf("%s", op);
        break;
      }
      b[now]++;
      if (res == -1)
        res = a[now][2];
      else {
        b[now] = 1;
        a[now][1] = res;
        res = -1;
        printf("? %d %d\n", a[now][1], a[now][2]);
        fflush(stdout);
        scanf("%s", op);
        if (op[0] == '>') swap(a[now][1], a[now][2]);
      }
    }
    printf("!\n");
    fflush(stdout);
  }
}
