#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, M = 1e6 + 10, inf = 1e9 + 10, mod = 1e9 + 7;
const long long INF = 1e18 + 10;
struct is {
  int mx, mi;
  void pushin(int x, int y) {
    mi = x;
    mx = y;
  }
} a[N], b[N];
char ch[10];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    int si = 0;
    for (int i = 1; i + 1 <= n; i += 2) {
      printf("? %d %d\n", i, i + 1);
      fflush(stdout);
      scanf("%s", ch);
      if (ch[0] == '=')
        a[si++].pushin(i, i + 1);
      else if (ch[0] == '<')
        a[si++].pushin(i, i + 1);
      else
        a[si++].pushin(i + 1, i);
    }
    if (n % 2) a[si++].pushin(n, n);
    while (1) {
      if (si == 1) break;
      int siz = 0;
      for (int i = 0; i + 1 < si; i += 2) {
        int minn, maxx;
        printf("? %d %d\n", a[i].mi, a[i + 1].mi);
        fflush(stdout);
        scanf("%s", ch);
        if (ch[0] == '=')
          minn = a[i].mi;
        else if (ch[0] == '<')
          minn = a[i].mi;
        else
          minn = a[i + 1].mi;
        printf("? %d %d\n", a[i].mx, a[i + 1].mx);
        fflush(stdout);
        scanf("%s", ch);
        if (ch[0] == '=')
          maxx = a[i].mx;
        else if (ch[0] == '<')
          maxx = a[i + 1].mx;
        else
          maxx = a[i].mx;
        b[siz++].pushin(minn, maxx);
      }
      if (si % 2) b[siz++] = a[si - 1];
      for (int i = 0; i < siz; i++) a[i] = b[i];
      si = siz;
    }
    printf("! %d %d\n", a[0].mi, a[0].mx);
    fflush(stdout);
  }
  return 0;
}
