#include <bits/stdc++.h>
using namespace std;
int bet[205];
bool Ask(int a, int b) {
  cout << "? " << a << ' ' << b << endl;
  char c;
  cin >> c;
  if (c == '>') return true;
  if (c == '<') return false;
}
void work() {
  int n;
  cin >> n;
  for (int i = 2; i <= 2 * n; i += 2) {
    if (Ask(i, i - 1)) {
      bet[i >> 1] = i - 1;
    } else {
      bet[i >> 1] = i;
    }
  }
  sort(bet + 1, bet + n + 1, Ask);
  int x, y;
  x = y = bet[1];
  if (x & 1)
    x = x + 1;
  else
    x = x - 1;
  for (int i = 1; i <= 2 * n; i++) {
    bet[i] = i;
  }
  if (x != 2) {
    swap(bet[x], bet[1]);
    swap(bet[y], bet[2]);
  } else {
    swap(bet[x], bet[1]);
  }
  sort(bet + 3, bet + 2 * n + 1, Ask);
  Ask(bet[n + 1], bet[2]);
  cout << '!' << endl;
  return;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    work();
  }
  return 0;
}
