#include <bits/stdc++.h>
unsigned L[55], H[55], Pi;
unsigned S[55], Si;
char ask(unsigned a, unsigned b) {
  printf("? %u %u\n", a, b);
  fflush(stdout);
  char c;
  while ((c = getchar()) <= ' ')
    ;
  return c;
}
int main() {
  unsigned t, n, i;
  char c, d;
  for (scanf("%u", &t); t--;) {
    scanf("%u", &n);
    Si = Pi = 0;
    for (i = 0; ++i <= n;) S[Si++] = i;
    while (Si + Pi > 1) {
      if (Si > 1) {
        c = ask(S[Si - 1], S[Si - 2]);
        if (c == '>') {
          H[Pi] = S[Si - 1];
          L[Pi] = S[Si - 2];
          ++Pi;
          --Si;
        }
        if (c == '<') {
          H[Pi] = S[Si - 2];
          L[Pi] = S[Si - 1];
          ++Pi;
          --Si;
        }
        --Si;
        continue;
      }
      if (Pi > 1) {
        c = ask(H[Pi - 1], H[Pi - 2]);
        d = ask(L[Pi - 1], L[Pi - 2]);
        if (c == '>') H[Pi - 2] = H[Pi - 1];
        if (d == '<') L[Pi - 2] = L[Pi - 1];
        --Pi;
        continue;
      }
      c = ask(H[Pi - 1], S[Si - 1]);
      d = ask(L[Pi - 1], S[Si - 1]);
      if (c == '<') H[Pi - 1] = S[Si - 1];
      if (d == '>') L[Pi - 1] = S[Si - 1];
      --Si;
    }
    if (Si) printf("! %u %u\n", S[Si - 1], S[Si - 1]);
    if (Pi) printf("! %u %u\n", L[Pi - 1], H[Pi - 1]);
    fflush(stdout);
  }
  return 0;
}
