#include <bits/stdc++.h>
using namespace std;
inline bool que(int a, int b) {
  printf("? %d %d\n", a, b);
  fflush(stdout);
  char ans;
  scanf(" %c", &ans);
  return ans == '>';
}
inline void End() {
  puts("!");
  fflush(stdout);
}
const int NN = 2e2 + 10;
pair<int, pair<int, int> > p[NN];
int rk[NN];
void solve() {
  int n, N;
  scanf("%d", &n);
  N = n;
  for (int i = 1; i <= n; i++) p[i] = {0, {i * 2 - 1, i * 2}};
  for (int i = 1; i <= n; i++) {
    if (que(p[i].second.first, p[i].second.second) == true)
      swap(p[i].second.first, p[i].second.second);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (i != j) {
        if (que(p[i].second.first, p[j].second.first)) p[i].first--;
      }
  }
  sort(p + 1, p + n + 1);
  N = (N + 1) / 2;
  while (n > N) {
    if (que(p[n - 1].second.first, p[n].second.second)) {
      n--;
    } else {
      p[n - 1].second.first = p[n].second.second;
      n--;
      if (que(p[n].second.first, p[n].second.second))
        swap(p[n].second.first, p[n].second.second);
      for (int i = n; i > 1 && que(p[i].second.first, p[i - 1].second.first);
           swap(p[i], p[i - 1]), i--)
        ;
    }
  }
  End();
}
int main() {
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
