#include <bits/stdc++.h>
using namespace std;
void test() { cerr << "\n"; }
template <typename T, typename... Args>
void test(T x, Args... args) {
  cerr << x << " ";
  test(args...);
}
const int MAXN = (int)1e5 + 5;
const int MOD = (int)1e9 + 7;
int a[205][205];
int query(int x, int y) {
  if (a[x][y] != -1) return a[x][y];
  int& ret = a[x][y];
  string s;
  cout << "? " << x << " " << y << endl;
  cin >> s;
  ret = s[0] == '>';
  a[y][x] = (!ret);
  return ret;
}
bool cmp(int x, int y) { return a[x][y]; }
void Sort(vector<int>& ve) {
  for (int i = 0; i < ve.size(); i++) {
    for (int j = i + 1; j < ve.size(); j++) {
      query(ve[i], ve[j]);
    }
  }
  sort(ve.begin(), ve.end(), cmp);
}
int rk[205];
void solve() {
  memset(a, -1, sizeof a);
  int n;
  cin >> n;
  vector<pair<int, int> > ve;
  vector<int> tmp;
  for (int i = 1; i <= n; i++) {
    if (query(i, i + n))
      ve.push_back({i, n + i});
    else
      ve.push_back({n + i, i});
    tmp.push_back(ve.back().second);
  }
  Sort(tmp);
  for (int i = 0; i < tmp.size(); i++) rk[tmp[i]] = i;
  sort(ve.begin(), ve.end(),
       [&](const pair<int, int>& a, const pair<int, int>& b) {
         return rk[a.second] < rk[b.second];
       });
  tmp.clear();
  for (int i = 1; i < ve.size(); i++) {
    tmp.push_back(ve[i].first);
    tmp.push_back(ve[i].second);
  }
  Sort(tmp);
  query(ve[0].second, tmp[n - 2]);
  cout << "!" << endl;
}
int main() {
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
