#include <bits/stdc++.h>
using namespace std;
const int LEN = 200005;
int n;
char inp() {
  char s[3];
  scanf("%s", s);
  return s[0];
}
vector<int> ini, sup, inf;
void ask() {
  int i = 0;
  sup.clear();
  inf.clear();
  while (i + 1 < ((int)(ini).size())) {
    int j = ini[i++];
    int k = ini[i++];
    printf("? %d %d \n", j, k);
    fflush(stdout);
    if (inp() == '>') swap(j, k);
    inf.push_back(j), sup.push_back(k);
  }
  if (i < ((int)(ini).size())) sup.push_back(ini[i]), inf.push_back(ini[i]);
  ini.clear();
}
int main() {
  int ntc;
  scanf("%d", &ntc);
  while (ntc--) {
    scanf("%d", &n);
    vector<int> Sup, Inf;
    ini.clear();
    sup.clear();
    inf.clear();
    for (int i = 1; i < n + 1; i++) ini.push_back(i);
    ask();
    Sup.clear();
    Inf.clear();
    for (int i = 0; i < ((int)(sup).size()); i++) Sup.push_back(sup[i]);
    for (int i = 0; i < ((int)(inf).size()); i++) Inf.push_back(inf[i]);
    ini.clear();
    for (int i = 0; i < ((int)(Sup).size()); i++) ini.push_back(Sup[i]);
    while (((int)(ini).size()) > 1) {
      ask();
      for (int i = 0; i < ((int)(sup).size()); i++) ini.push_back(sup[i]);
    }
    int ans_max = ini[0];
    ini.clear();
    for (int i = 0; i < ((int)(Inf).size()); i++) ini.push_back(Inf[i]);
    while (((int)(ini).size()) > 1) {
      ask();
      for (int i = 0; i < ((int)(inf).size()); i++) ini.push_back(inf[i]);
    }
    int ans_min = ini[0];
    printf("! %d %d\n", ans_min, ans_max);
    fflush(stdout);
  }
  return 0;
}
