#include <bits/stdc++.h>
using namespace std;
long long n, t, sum;
char c;
int main() {
  cin >> t;
  for (int rr = 0; rr < t; rr++) {
    cin >> n;
    if (n == 1) {
      cout << "! " << 1 << " " << 1 << '\n';
      continue;
    }
    sum = 0;
    vector<long long> v, z;
    for (int i = 1; i <= n; i++) {
      v.push_back(i);
    }
    while (v.size() > 1) {
      vector<long long> w;
      sum++;
      for (int i = 0; i < v.size(); i += 2) {
        if (i < v.size() - 1) {
          cout << "? " << v[i] << " " << v[i + 1] << '\n';
          fflush(stdout);
          cin >> c;
          if (c != '<') {
            w.push_back(v[i]);
            if (sum == 1) {
              z.push_back(v[i + 1]);
            }
          } else {
            w.push_back(v[i + 1]);
            if (sum == 1) {
              z.push_back(v[i]);
            }
          }
        } else {
          w.push_back(v[i]);
          if (sum == 1) {
            z.push_back(v[i]);
          }
        }
      }
      v = w;
    }
    while (z.size() > 1) {
      vector<long long> q;
      for (int i = 0; i < z.size(); i += 2) {
        if (i < z.size() - 1) {
          cout << "? " << z[i] << " " << z[i + 1] << '\n';
          fflush(stdout);
          cin >> c;
          if (c != '<') {
            q.push_back(z[i + 1]);
          } else {
            q.push_back(z[i]);
          }
        } else {
          q.push_back(z[i]);
        }
      }
      z = q;
    }
    cout << "! " << z[0] << " " << v[0] << '\n';
  }
}
