#include <bits/stdc++.h>
using namespace std;
const long double ZERO = 1e-15;
const long double EPS = 1e-10;
const long long MAXN = 100500;
const long long INF9 = 2 * 1e9;
const long long INF = 4 * 1e18;
const long long L0 = 0;
const long double PI = acos(-1);
const long double sq2 = sqrt(2.0);
long long req(long long a, long long b) {
  cout << "? " << a + 1 << ' ' << b + 1 << endl;
  fflush(stdout);
  char c;
  cin >> c;
  return (c == '=' ? 0 : c == '>' ? 1 : -1);
}
void ans(long long a, long long b) {
  cout << "! " << a + 1 << ' ' << b + 1 << endl;
  fflush(stdout);
}
int main() {
  {
    ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
  }
  long long q;
  cin >> q;
  while (q--) {
    long long n;
    cin >> n;
    if (n == 1) {
      cout << "! 1 1" << endl;
      continue;
    }
    long long mi = 0, ma = 1;
    if (req(mi, ma) > 0) swap(mi, ma);
    long long done = 2;
    while (true) {
      if (done >= n) break;
      long long tmi = done, tma = tmi + 1;
      if (tma == n) {
        tma = tmi;
        done++;
      } else {
        done += 2;
        if (req(tmi, tma) > 0) swap(tmi, tma);
      }
      if (req(tma, ma) > 0) ma = tma;
      if (req(tmi, mi) < 0) mi = tmi;
    }
    ans(mi, ma);
  }
  return 0;
}
