#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> bi, sm;
string op;
int main() {
  ios::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    if (n == 1) {
      cout << "! 1 1" << endl;
      continue;
    }
    bi.clear();
    sm.clear();
    for (long long i = 1; i <= n; i++) {
      if ((n & 1) && i == n) {
        cout << "? 1 " << i << endl;
        cin >> op;
        if (op == "<")
          bi.push_back(i);
        else
          sm.push_back(i);
      } else if (i & 1) {
        cout << "? " << i << " " << i + 1 << endl;
        cin >> op;
        if (op == ">")
          bi.push_back(i), sm.push_back(i + 1);
        else
          bi.push_back(i + 1), sm.push_back(i);
      }
    }
    long long ans1 = bi[0];
    for (long long i = 1; i <= (long long)bi.size() - 1; i++) {
      cout << "? " << ans1 << " " << bi[i] << endl;
      cin >> op;
      if (op == "<") ans1 = bi[i];
    }
    long long ans2 = sm[0];
    for (long long i = 1; i <= (long long)sm.size() - 1; i++) {
      cout << "? " << ans2 << " " << sm[i] << endl;
      cin >> op;
      if (op == ">") ans2 = sm[i];
    }
    cout << "! " << ans2 << " " << ans1 << endl;
  }
  return 0;
}
