#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, sum, ans, T;
char c;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    vector<int> v, b;
    for (int i = 1; i <= n; i += 2) {
      if (i + 1 > n) {
        v.push_back(i);
        b.push_back(i);
      } else {
        printf("? %d %d\n", i, i + 1);
        fflush(stdout);
        scanf(" %c", &c);
        if (c == '<')
          v.push_back(i + 1), b.push_back(i);
        else if (c == '>')
          v.push_back(i), b.push_back(i + 1);
        else
          v.push_back(i), b.push_back(i);
      }
    }
    while (v.size() > 1) {
      x = v[v.size() - 1];
      v.pop_back();
      y = v[v.size() - 1];
      v.pop_back();
      printf("? %d %d\n", x, y);
      fflush(stdout);
      scanf(" %c", &c);
      if (c == '<')
        v.push_back(y);
      else if (c == '>')
        v.push_back(x);
      else
        v.push_back(x);
    }
    while (b.size() > 1) {
      x = b[b.size() - 1];
      b.pop_back();
      y = b[b.size() - 1];
      b.pop_back();
      printf("? %d %d\n", x, y);
      fflush(stdout);
      scanf(" %c", &c);
      if (c == '<')
        b.push_back(x);
      else if (c == '>')
        b.push_back(y);
      else
        b.push_back(x);
    }
    printf("! %d %d\n", b[0], v[0]);
    fflush(stdout);
  }
  return 0;
}
