#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;
using namespace std;
bool q(int x, int y) {
  cout << "? " << x + 1 << " " << y + 1 << endl;
  string s;
  cin >> s;
  return s == "<";
}
int best(vector<int> v) {
  int b = v[0];
  for (int i = 1; i < v.size(); ++i) {
    for (int j = 0; j < i; ++j) {
      bool r = q(v[j], v[i]);
      if (r && b == v[j]) {
        b = v[i];
      }
    }
  }
  return b;
}
void solve() {
  int n;
  cin >> n;
  vector<int> h;
  vector<int> l;
  for (int i = 0; i < 2 * n; i += 2) {
    int b = best({i, i + 1});
    h.push_back(b);
    l.push_back(b ^ 1);
  }
  int b = best(l) ^ 1;
  h.erase(find(h.begin(), h.end(), b));
  int q = best(h);
  vector<int> all;
  for (int i = 0; i < 2 * n; ++i) {
    if (i != b && i != q) {
      all.push_back(i);
    }
  }
  best(all);
  cout << "!" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(20);
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    solve();
  }
}
