#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void chkmax(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline void chkmin(T& x, U y) {
  if (y < x) x = y;
}
vector<int> L, R;
char cmp[11];
int calc(vector<int> V, int id) {
  vector<int> S;
  while (V.size() > 1) {
    int n = V.size();
    S.clear();
    for (int i = 0; i < n - 1; i += 2) {
      printf("? %d %d\n", V[i], V[i + 1]);
      fflush(stdout);
      scanf("%s", cmp);
      if (id == 0) {
        if (cmp[0] == '<') {
          S.push_back(V[i]);
        } else
          S.push_back(V[i + 1]);
      } else {
        if (cmp[0] == '>') {
          S.push_back(V[i]);
        } else
          S.push_back(V[i + 1]);
      }
    }
    if (n % 2) S.push_back(V[n - 1]);
    V = S;
  }
  return V[0];
}
int main() {
  int ncase;
  for (scanf("%d", &ncase); ncase--;) {
    int n;
    scanf("%d", &n);
    if (n == 1) {
      puts("! 1 1");
      fflush(stdout);
      continue;
    }
    L.clear(), R.clear();
    for (int i = 1; i < n; i += 2) {
      printf("? %d %d\n", i, i + 1);
      fflush(stdout);
      scanf("%s", cmp);
      if (cmp[0] == '<') {
        L.push_back(i);
        R.push_back(i + 1);
      } else {
        L.push_back(i + 1);
        R.push_back(i);
      }
    }
    if (n % 2) L.push_back(n), R.push_back(n);
    int l = calc(L, 0), r = calc(R, 1);
    printf("! %d %d\n", l, r);
    fflush(stdout);
  }
  return 0;
}
