#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 205;
const int INF = 1000000000;
vector<int> x, mi, ma;
int maxans() {
  char c;
  while (ma.size() != 1) {
    x.clear();
    x = ma;
    ma.clear();
    for (int i = 0; i < x.size(); i += 2) {
      if (i == x.size() - 1)
        ma.push_back(x[i]);
      else {
        cout << "? " << x[i] << " " << x[i + 1] << "\n";
        fflush(stdout);
        cin >> c;
        if (c == '=') ma.push_back(x[i]);
        if (c == '>') ma.push_back(x[i]);
        if (c == '<') ma.push_back(x[i + 1]);
      }
    }
  }
  return ma[0];
}
int minans() {
  char c;
  while (mi.size() != 1) {
    x.clear();
    x = mi;
    mi.clear();
    for (int i = 0; i < x.size(); i += 2) {
      if (i == x.size() - 1)
        mi.push_back(x[i]);
      else {
        cout << "? " << x[i] << " " << x[i + 1] << "\n";
        fflush(stdout);
        cin >> c;
        if (c == '=') mi.push_back(x[i]);
        if (c == '<') mi.push_back(x[i]);
        if (c == '>') mi.push_back(x[i + 1]);
      }
    }
  }
  return mi[0];
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    char c;
    cin >> n;
    x.clear();
    mi.clear();
    ma.clear();
    if (n == 1) {
      cout << "! 1 1\n";
      fflush(stdout);
      continue;
    }
    for (int i = 1; i <= n; i += 2) {
      if (i == n) {
        mi.push_back(i);
        ma.push_back(i);
      } else {
        cout << "? " << i << " " << i + 1 << "\n";
        fflush(stdout);
        cin >> c;
        if (c == '=') {
          mi.push_back(i);
          ma.push_back(i + 1);
        }
        if (c == '>') {
          ma.push_back(i);
          mi.push_back(i + 1);
        }
        if (c == '<') {
          mi.push_back(i);
          ma.push_back(i + 1);
        }
      }
    }
    int q, w;
    q = minans();
    w = maxans();
    cout << "! " << q << " " << w << "\n";
    fflush(stdout);
  }
  return 0;
}
