#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;
long long mod = 998244353;
long double inf = 1e9;
long double eps = 1e-8;
long double pi = acos(-1);
ifstream in("input.txt");
ofstream out("output.txt");
int ask(int x, int y) {
  cout << "? " << x + 1 << " " << y + 1 << endl;
  char ch;
  cin >> ch;
  return (ch == '<') ? x : y;
}
void solve() {
  int n;
  cin >> n;
  int m1 = ask(0, 1);
  set<int> a;
  a.insert(0);
  a.insert(1);
  set<int> b;
  b.insert(2);
  int m2 = 2;
  for (int i = 3; i < n + 1; i++) {
    m2 = ask(m2, i);
    b.insert(i);
  }
  for (int i = n + 1; i < 2 * n; i++) {
    if (ask(m2, m1) == m2) {
      b.erase(m2);
      m2 = i;
      for (auto v : b) {
        m2 = ask(m2, v);
      }
      b.insert(i);
    } else {
      a.erase(m1);
      m1 = i;
      for (auto v : a) {
        m1 = ask(m1, v);
      }
      a.insert(i);
    }
  }
  ask(m1, m2);
  cout << "!" << endl;
}
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    solve();
  }
  return 0;
}
