#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
bool is_prime(int n) {
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
inline long long getPow(long long a, long long b) {
  long long res = 1ll, tp = a;
  while (b) {
    if (b & 1ll) {
      res *= tp;
    }
    tp *= tp;
    b >>= 1ll;
  }
  return res;
}
inline long long nxt() {
  long long x;
  cin >> x;
  return x;
}
void ok() {
  puts("YES");
  exit(0);
}
void no() {
  puts("NO");
  exit(0);
}
long long xx[] = {-1, 1, 0, 0};
long long yy[] = {0, 0, -1, 1};
const int N = 211111;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = nxt();
  while (t--) {
    long long n = nxt();
    vector<long long> mx;
    vector<long long> mn;
    vector<long long> r;
    long long ind = n;
    for (int i = 2; i <= n; i += 2) {
      cout << "? " << i - 1 << " " << i << endl;
      fflush(stdout);
      char c;
      cin >> c;
      if (c == '>') {
        mx.push_back(i - 1);
        mn.push_back(i);
      } else {
        mx.push_back(i);
        mn.push_back(i - 1);
      }
    }
    if (n % 2) {
      mx.push_back(n);
      mn.push_back(n);
    }
    long long ans_1 = mx[0], ans_2 = mn[0];
    for (int i = 1; i < mx.size(); i += 1) {
      cout << "? " << ans_1 << " " << mx[i] << endl;
      fflush(stdout);
      char c;
      cin >> c;
      if (c == '<') {
        ans_1 = mx[i];
      }
    }
    for (int i = 1; i < mn.size(); i += 1) {
      cout << "? " << ans_2 << " " << mn[i] << endl;
      fflush(stdout);
      char c;
      cin >> c;
      if (c == '>') {
        ans_2 = mn[i];
      }
    }
    cout << "! " << ans_2 << " " << ans_1 << endl;
    fflush(stdout);
  }
  return 0;
}
