#include <bits/stdc++.h>
using namespace std;
int T, n, mx, mn, a[50], b[50];
char c;
int solve_max(int l, int r) {
  if (l == r) return a[l];
  int m = (l + r) / 2;
  int L = solve_max(l, m);
  int R = solve_max(m + 1, r);
  cout << "? " << L << " " << R << endl;
  cin >> c;
  if (c == '>') return L;
  return R;
}
int solve_min(int l, int r) {
  if (l == r) return b[l];
  int m = (l + r) / 2;
  int L = solve_min(l, m);
  int R = solve_min(m + 1, r);
  cout << "? " << L << " " << R << endl;
  cin >> c;
  if (c == '<') return L;
  return R;
}
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    mx = mn = 1;
    if (n > 1) {
      a[0] = b[0] = 0;
      for (int i = 1; i < n; i += 2) {
        int j = i + 1;
        cout << "? " << i << " " << j << endl;
        cin >> c;
        if (c == '=')
          a[++a[0]] = i, b[++b[0]] = j;
        else if (c == '<')
          a[++a[0]] = j, b[++b[0]] = i;
        else
          a[++a[0]] = i, b[++b[0]] = j;
      }
      if (n % 2) {
        cout << "? " << a[a[0]] << " " << n << endl;
        cin >> c;
        if (c == '<') a[a[0]] = n;
        cout << "? " << b[b[0]] << " " << n << endl;
        cin >> c;
        if (c == '>') b[b[0]] = n;
      }
      mx = solve_max(1, a[0]);
      mn = solve_min(1, b[0]);
    }
    cout << "! " << mn << " " << mx << endl;
  }
  return 0;
}
