#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int INF = 0x3f3f3f3f;
const long long MOD = 1e9 + 7;
int kase;
int n;
char op[2];
int big[MAXN], topb, sml[MAXN], tops;
void ask(int i, int j) {
  printf("? %d %d\n", i, j);
  fflush(stdout);
}
int red() {
  scanf("%s", op);
  if (op[0] == '<')
    return -1;
  else if (op[0] == '=')
    return 0;
  else
    return 1;
}
int main() {
  scanf("%d", &kase);
  while (kase--) {
    topb = tops = 0;
    scanf("%d", &n);
    if (n == 1) {
      printf("! %d %d\n", 1, 1);
      fflush(stdout);
      continue;
    }
    for (int i = 1; i < n; i += 2) {
      ask(i, i + 1);
      if (red() >= 0) {
        big[++topb] = i;
        sml[++tops] = i + 1;
      } else {
        big[++topb] = i + 1;
        sml[++tops] = i;
      }
    }
    while (topb > 1) {
      int x = big[topb--];
      int y = big[topb--];
      ask(x, y);
      if (red() >= 0) {
        big[++topb] = x;
      } else {
        big[++topb] = y;
      }
    }
    while (tops > 1) {
      int x = sml[tops--];
      int y = sml[tops--];
      ask(x, y);
      if (red() <= 0) {
        sml[++tops] = x;
      } else {
        sml[++tops] = y;
      }
    }
    if (n & 1) {
      ask(n, big[1]);
      if (red() >= 0) {
        big[1] = n;
      }
      ask(n, sml[1]);
      if (red() <= 0) {
        sml[1] = n;
      }
    }
    printf("! %d %d\n", sml[1], big[1]);
    fflush(stdout);
  }
  return 0;
}
