#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const long long int P = 1000000007;
const double eps = 1e-6;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int solve(set<int> &second) {
  int ans = *second.begin();
  for (auto i : second) {
    if (ans == i) continue;
    cout << "? " << ans << " " << i << endl;
    char c;
    cin >> c;
    if (c == '>') ans = i;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  for (long long int test = 1; test <= t; test++) {
    int n;
    cin >> n;
    int nn = 2 * n;
    set<int> left, right = {n, n + 1};
    for (int i = 1; i <= (n - 1); i++) left.insert(i);
    for (int i = n + 2; i <= (nn + 1); i++) {
      int one = solve(left);
      int two = solve(right);
      cout << "? " << one << " " << two << endl;
      char c;
      cin >> c;
      if (c == '<') {
        left.erase(one);
        left.insert(i);
      } else {
        right.erase(two);
        right.insert(i);
      }
    }
    cout << "!" << endl;
  }
  cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
