#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (n == 1) {
      printf("! 1 1\n");
      fflush(stdout);
      continue;
    }
    vector<pair<int, int> > v1, v;
    char c[5];
    for (int i = 1; i < n; i += 2) {
      printf("? %d %d\n", i, i + 1);
      fflush(stdout);
      scanf("%s", c);
      if (c[0] == '>' || c[0] == '=') {
        v.push_back(make_pair(i, i + 1));
      } else
        v.push_back(make_pair(i + 1, i));
    }
    if (n % 2) {
      v.push_back(make_pair(n, n));
    }
    while (v.size() > 1) {
      for (int i = 0; i < v.size() - 1; i += 2) {
        int u, u1;
        u = v[i].first;
        u1 = v[i + 1].first;
        printf("? %d %d\n", u, u1);
        fflush(stdout);
        scanf("%s", c);
        if (c[0] == '>' || c[0] == '=') {
          v1.push_back(make_pair(u, 0));
        } else
          v1.push_back(make_pair(u1, 0));
        u = v[i].second;
        u1 = v[i + 1].second;
        printf("? %d %d\n", u, u1);
        fflush(stdout);
        scanf("%s", c);
        if (c[0] == '<') {
          v1.back().second = u;
        } else
          v1.back().second = u1;
      }
      if (v.size() % 2) {
        v1.push_back(v.back());
      }
      swap(v, v1);
      v1.clear();
    }
    printf("! %d %d\n", v[0].second, v[0].first);
    fflush(stdout);
  }
}
