#include <bits/stdc++.h>
using namespace std;
int t, n;
vector<int> v[2];
bool pmm(int a, int b) {
  cout << "? " << a << " " << b << endl;
  char c;
  cin >> c;
  return c == '>' ? 1 : 0;
}
void sgr(int a, int i) {
  v[i].push_back(a);
  for (int j = (int)v[i].size() - 1; j > 0; --j) {
    if (pmm(v[i][j - 1], v[i][j])) break;
    swap(v[i][j - 1], v[i][j]);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  for (int j = 1; j <= t; ++j) {
    v[0].clear();
    v[1].clear();
    cin >> n;
    for (int i = 1; i <= n + 1; ++i) {
      sgr(i, i & 1);
    }
    for (int i = n + 2; i <= 2 * n; ++i) {
      if (pmm(v[0].back(), v[1].back())) {
        v[1].pop_back();
        sgr(i, 1);
      } else {
        v[0].pop_back();
        sgr(i, 0);
      }
    }
    if (pmm(v[0].back(), v[1].back())) {
      v[1].pop_back();
    } else {
      v[0].pop_back();
    }
    cout << "!" << endl;
  }
  return 0;
}
