#include <bits/stdc++.h>
using namespace std;
int QA(int x, int y) {
  printf("? %d %d\n", x, y);
  fflush(stdout);
  char c;
  while (scanf("%c", &c) == 1 && c != '>' && c != '=' && c != '<')
    ;
  int temp = 0;
  if (c == '<') temp = 1;
  if (c == '>') temp = -1;
  return temp;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    int fmin, fmax;
    if (n % 2 == 1)
      fmin = fmax = 1;
    else if (QA(1, 2) > 0)
      fmin = 1, fmax = 2;
    else
      fmin = 2, fmax = 1;
    for (int i = (n % 2 == 1 ? 2 : 3); i <= n; i += 2) {
      if (QA(i, i + 1) > 0) {
        if (QA(i, fmin) > 0) fmin = i;
        if (QA(fmax, i + 1) > 0) fmax = i + 1;
      } else {
        if (QA(i + 1, fmin) > 0) fmin = i + 1;
        if (QA(fmax, i) > 0) fmax = i;
      }
    }
    printf("! %d %d\n", fmin, fmax);
    fflush(stdout);
  }
  return 0;
}
