#include <bits/stdc++.h>
int main() {
  int T, n, i, mx[100], mn[100];
  char c;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (i = 1; i <= n / 2; i++) printf("? %d %d\n", 2 * i - 1, 2 * i);
    fflush(stdout);
    for (i = 1; i <= n / 2; i++) {
      getchar();
      c = getchar();
      if (c == '>')
        mx[i] = 2 * i - 1, mn[i] = 2 * i;
      else
        mx[i] = 2 * i, mn[i] = 2 * i - 1;
    }
    if (n % 2 == 1) mx[n / 2 + 1] = mn[n / 2 + 1] = n;
    for (i = 2; i <= (n + 1) / 2; i++) {
      printf("? %d %d\n", mx[1], mx[i]);
      printf("? %d %d\n", mn[1], mn[i]);
      fflush(stdout);
      getchar();
      c = getchar();
      if (c == '<' || c == '=') mx[1] = mx[i];
      getchar();
      c = getchar();
      if (c == '>') mn[1] = mn[i];
    }
    printf("! %d %d\n", mn[1], mx[1]);
    fflush(stdout);
  }
  return 0;
}
