#include <bits/stdc++.h>
using namespace std;
void solve() {
  queue<int> large, small;
  int n;
  char c;
  scanf("%d", &n);
  if (n == 1) {
    printf("! 1 1\n");
    fflush(stdout);
    return;
  }
  if (n % 2 == 1) {
    printf("? 1 2\n");
    fflush(stdout);
    scanf(" %c", &c);
    if (c == '<' || c == '=') {
      small.push(1);
    } else {
      large.push(1);
    }
  }
  for (int i = n % 2 + 1; i <= n; i += 2) {
    printf("? %d %d\n", i, i + 1);
    fflush(stdout);
    scanf(" %c", &c);
    if (c == '<' || c == '=') {
      small.push(i);
      large.push(i + 1);
    } else {
      large.push(i);
      small.push(i + 1);
    }
  }
  while (large.size() > 1) {
    int a = large.front();
    large.pop();
    int b = large.front();
    large.pop();
    printf("? %d %d\n", a, b);
    fflush(stdout);
    scanf(" %c", &c);
    if (c == '<' || c == '=') {
      large.push(b);
    } else {
      large.push(a);
    }
  }
  while (small.size() > 1) {
    int a = small.front();
    small.pop();
    int b = small.front();
    small.pop();
    printf("? %d %d\n", a, b);
    fflush(stdout);
    scanf(" %c", &c);
    if (c == '<' || c == '=') {
      small.push(a);
    } else {
      small.push(b);
    }
  }
  printf("! %d %d\n", small.front(), large.front());
  fflush(stdout);
}
int main() {
  int T;
  scanf("%d", &T);
  for (int i = 0; i < T; i++) {
    solve();
  }
  return 0;
}
