#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3fll;
inline int RAND() {
  static int x = 880301;
  return x = (x * 0xdefacedll + 1ll) % 0x7fffffffll;
}
inline int query(int a, int b) {
  if (a == b) return 0;
  printf("? %d %d\n", a, b);
  fflush(stdout);
  char s[5];
  scanf("%s", s);
  if (s[0] == '<')
    return -1;
  else if (s[0] == '>')
    return 1;
  else
    return 0;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    int mn, mx;
    if (n & 1)
      mn = mx = 1;
    else {
      mn = 1, mx = 2;
      if (query(mn, mx) == 1) swap(mn, mx);
    }
    for (int i = ((n & 1) ? 2 : 3); i <= n; i += 2) {
      int a = i, b = i + 1;
      if (query(a, b) == 1) swap(a, b);
      if (query(mn, a) == 1) mn = a;
      if (query(b, mx) == 1) mx = b;
    }
    printf("! %d %d\n", mn, mx);
    fflush(stdout);
  }
  return 0;
}
