#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t, n, i, j, k, a, b;
  string s;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> aa, bb;
    for (i = 0; i + 1 < n; i += 2) {
      cout << "? " << i + 1 << " " << i + 2 << "\n";
      cout.flush();
      cin >> s;
      if (s == "<") {
        aa.push_back(i + 1);
        bb.push_back(i + 2);
      } else {
        bb.push_back(i + 1);
        aa.push_back(i + 2);
      }
    }
    if (n % 2 == 1) {
      aa.push_back(n);
      bb.push_back(n);
    }
    a = aa[0];
    for (i = 1; i < aa.size(); i++) {
      cout << "? " << a << " " << aa[i] << "\n";
      cout.flush();
      cin >> s;
      if (s != "<") a = aa[i];
    }
    b = bb[0];
    for (i = 1; i < bb.size(); i++) {
      cout << "? " << b << " " << bb[i] << "\n";
      cout.flush();
      cin >> s;
      if (s != ">") b = bb[i];
    }
    cout << "! " << a << " " << b << "\n";
    cout.flush();
  }
  return 0;
}
