#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
vector<int> small, big;
void Solve() {
  int n, i, idx, s, b;
  char r;
  cin >> n;
  small.clear();
  big.clear();
  for (i = 1; i < n; i += 2) {
    printf("? %d %d\n", i, i + 1);
    fflush(stdout);
    cin >> r;
    switch (r) {
      case '<':
        small.push_back(i);
        big.push_back(i + 1);
        break;
      default:
        small.push_back(i + 1);
        big.push_back(i);
    }
  }
  if (n & 1) {
    small.push_back(n);
    big.push_back(n);
  }
  idx = small[0];
  for (i = 1; i < small.size(); i++) {
    printf("? %d %d\n", idx, small[i]);
    fflush(stdout);
    cin >> r;
    if (r == '>') idx = small[i];
  }
  s = idx;
  idx = big[0];
  for (i = 1; i < big.size(); i++) {
    printf("? %d %d\n", idx, big[i]);
    fflush(stdout);
    cin >> r;
    if (r == '<') idx = big[i];
  }
  b = idx;
  printf("! %d %d\n", s, b);
  fflush(stdout);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) Solve();
  return 0;
}
