#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int g = 0; g < t; ++g) {
    int n;
    cin >> n;
    vector<int> v3;
    vector<int> v4;
    for (int i = 1; i <= n - n % 2; i += 2) {
      cout << "? " << i << " " << i + 1 << endl;
      char a;
      cin >> a;
      fflush(stdout);
      if (a == '=') {
        v3.push_back(i);
        v4.push_back(i + 1);
      }
      if (a == '<') {
        v3.push_back(i);
        v4.push_back(i + 1);
      }
      if (a == '>') {
        v4.push_back(i);
        v3.push_back(i + 1);
      }
    }
    if (n % 2 == 1) {
      v3.push_back(n);
      v4.push_back(n);
    }
    while (v3.size() > 1) {
      vector<int> v1;
      vector<int> v2;
      for (int i = 0; i < v3.size() - v3.size() % 2; i += 2) {
        cout << "? " << v3[i] << " " << v3[i + 1] << endl;
        fflush(stdout);
        char a;
        cin >> a;
        if (a == '=') {
          v1.push_back(v3[i]);
        }
        if (a == '<') {
          v1.push_back(v3[i]);
        }
        if (a == '>') {
          v1.push_back(v3[i + 1]);
        }
      }
      if (v3.size() % 2) {
        v1.push_back(v3[v3.size() - 1]);
      }
      v3.clear();
      for (int i = 0; i < v1.size(); ++i) {
        v3.push_back(v1[i]);
      }
      for (int i = 0; i < v4.size() - v4.size() % 2; i += 2) {
        cout << "? " << v4[i] << " " << v4[i + 1] << endl;
        fflush(stdout);
        char a;
        cin >> a;
        if (a == '=') {
          v2.push_back(v4[i]);
        }
        if (a == '<') {
          v2.push_back(v4[i + 1]);
        }
        if (a == '>') {
          v2.push_back(v4[i]);
        }
      }
      if (v4.size() % 2) {
        v2.push_back(v4[v4.size() - 1]);
      }
      v4.clear();
      for (int i = 0; i < v2.size(); ++i) {
        v4.push_back(v2[i]);
      }
    }
    cout << "! " << v3[0] << " " << v4[0] << endl;
  }
  return 0;
}
