#include <bits/stdc++.h>
using namespace std;
int q[205][205];
int query(int first, int second) {
  if (q[first][second] == -1) {
    printf("? %d %d\n", first, second);
    fflush(stdout);
    char c;
    scanf(" %c", &c);
    if (c == '>')
      q[first][second] = 1;
    else
      q[first][second] = 0;
  }
  return q[first][second];
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(q, -1, sizeof(q));
    int n;
    scanf("%d", &n);
    vector<int> v;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);
    v.push_back(4);
    if (!query(1, 3)) {
      swap(v[0], v[2]);
    }
    if (!query(2, 4)) {
      swap(v[1], v[3]);
    }
    if (!query(v[2], v[3])) {
      swap(v[0], v[1]);
      swap(v[2], v[3]);
    }
    for (int i = 5; i <= 2 * n; i++) {
      v.pop_back();
      v.push_back(i);
      if (!query(v[1], v[3])) swap(v[1], v[3]);
      if (!query(v[2], v[3])) {
        swap(v[0], v[1]);
        swap(v[2], v[3]);
      }
    }
    for (int i = 1; i <= 2 * n; i++)
      for (int j = 1; j <= 2 * n; j++) {
        if (i != v[0] && i != v[1] && j != v[0] && j != v[1] && i != j)
          query(i, j);
      }
    printf("!\n");
    fflush(stdout);
  }
}
