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