#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const double eps = 1e-10;
const long long inf = 0x3f3f3f3f3f3f3f3fLL;
const long long N = 2e5 + 5;
const long long MOD = 1e9 + 7;
long long pw(long long b, long long p) {
  b %= MOD;
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t, n;
  char res;
  cin >> t;
  while (t--) {
    cin >> n;
    long long mn, mx;
    if (n & 1) {
      mn = mx = 1;
    } else {
      cout << "? " << 1 << ' ' << 2 << endl;
      cin >> res;
      if (res == '<')
        mn = 1, mx = 2;
      else if (res == '>')
        mn = 2, mx = 1;
      else
        mn = mx = 1;
    }
    long long x, curmn, curmx;
    if (n & 1)
      x = 2;
    else
      x = 3;
    for (long long i = x; i <= n; i += 2) {
      cout << "? " << i << ' ' << i + 1 << endl;
      cin >> res;
      if (res == '<')
        curmn = i, curmx = i + 1;
      else if (res == '>')
        curmn = i + 1, curmx = i;
      else
        curmn = curmx = i;
      cout << "? " << mx << ' ' << curmx << endl;
      cin >> res;
      if (res == '<') mx = curmx;
      cout << "? " << mn << ' ' << curmn << endl;
      cin >> res;
      if (res == '>') mn = curmn;
    }
    cout << "! " << mn << ' ' << mx << endl;
  }
  return 0;
}
