#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "{";
  for (const T& v : vc) o << v << ",";
  o << "}";
  return o;
}
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool Lwin(int x, int y) {
  cout << "? " << x + 1 << " " << y + 1 << endl;
  char c;
  cin >> c;
  return c == '>';
}
int main() {
  int T;
  cin >> T;
  for (int _ = 0; _ < (int)(T); _++) {
    int N;
    cin >> N;
    V<int> a(N - 1), b(2);
    for (int i = 0; i < (int)(N - 1); i++) a[i] = i;
    b[0] = N - 1, b[1] = N;
    sort(a.begin(), a.end(), Lwin);
    sort(b.begin(), b.end(), Lwin);
    int c = -1;
    if (Lwin(a.back(), b.back())) {
      c = b.back();
      b.pop_back();
    } else {
      c = a.back();
      a.pop_back();
    }
    for (int x = N + 1; x < N + N; x++) {
      if (a.size() < b.size()) swap(a, b);
      if (Lwin(c, x)) continue;
      int j = b.size();
      for (int i = 0; i < (int)(b.size()); i++) {
        if (Lwin(x, b[i])) {
          j = i;
          break;
        }
      }
      b.insert(b.begin() + j, x);
      if (Lwin(a.back(), b.back())) {
        c = b.back();
        b.pop_back();
      } else {
        c = a.back();
        a.pop_back();
      }
    }
    cout << "!" << endl;
  }
}
