#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
vector<int> v1, v2;
bool query(int A, int B) {
  cout << "? " << A << " " << B << endl;
  fflush(stdout);
  char c;
  cin >> c;
  return c == '>';
}
void fixed1() {
  int iterator = 1;
  while (iterator) {
    if (!query(v1[iterator], v1[iterator - 1])) {
      swap(v1[iterator], v1[iterator - 1]);
      iterator--;
    } else
      break;
  }
}
void fixed2() {
  int iterator = v2.size() - 1;
  while (iterator) {
    if (!query(v2[iterator], v2[iterator - 1])) {
      swap(v2[iterator], v2[iterator - 1]);
      iterator--;
    } else
      break;
  }
}
void solve() {
  v1.clear();
  v2.clear();
  int n;
  cin >> n;
  for (int i = 1; i <= 2; ++i) {
    v1.push_back(i);
  }
  fixed1();
  for (int i = 3; i <= n + 1; ++i) {
    v2.push_back(i);
    fixed2();
  }
  for (int i = n + 2; i <= 2 * n; ++i) {
    if (query(v1[0], v2[0])) {
      for (int i = 1; i <= n - 2; ++i) {
        v2[i - 1] = v2[i];
      }
      v2[n - 2] = i;
      fixed2();
    } else {
      v1[0] = v1[1];
      v1[1] = i;
      fixed1();
    }
  }
  query(v1[0], v2[0]);
  cout << "!\n";
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
