#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int N = 110;
const int ms63 = 0x3f3f3f3f;
int casenum, casei;
void fre() { freopen("/home/hyf/Desktop/programs/in.txt", "r", stdin); }
int a[N], n, MIN, MAX, b[N];
char ch;
int NUM = 0;
void check(int a[], int n, int typ) {
  int ln = 0, rn = 0;
  int lft[N], rgt[N];
  for (int i = 1; i + 1 <= n; i += 2) {
    printf("? %d %d\n", a[i], a[i + 1]);
    fflush(stdout);
    scanf(" %c", &ch);
    if (ch == '<' || ch == '=') {
      lft[++ln] = a[i];
      rgt[++rn] = a[i + 1];
    } else {
      lft[++ln] = a[i + 1];
      rgt[++rn] = a[i];
    }
  }
  if (n & 1) lft[++ln] = a[n], rgt[++rn] = a[n];
  if (typ == 2) {
    if (ln > 1)
      check(lft, ln, 0);
    else
      MIN = lft[ln];
    if (rn > 1)
      check(rgt, rn, 1);
    else
      MAX = rgt[rn];
  } else if (typ == 0) {
    if (ln > 1)
      check(lft, ln, 0);
    else
      MIN = lft[ln];
  } else {
    if (rn > 1)
      check(rgt, rn, 1);
    else
      MAX = rgt[rn];
  }
}
int main() {
  scanf("%d", &casenum);
  for (casei = 1; casei <= casenum; casei++) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) a[i] = i;
    check(a, n, 2);
    printf("! %d %d\n", MIN, MAX);
    fflush(stdout);
  }
  return 0;
}
