#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
map<char, int> num;
int vis[55], arr[55];
int fn = 0;
int f(int x, int y) {
  printf("? %d %d\n", x, y);
  fflush(stdout);
  char res;
  scanf(" %c", &res);
  return num[res];
}
int main() {
  num['<'] = 0;
  num['='] = 1;
  num['>'] = 2;
  int t;
  scanf("%d", &t);
  while (t--) {
    memset(vis, 0, sizeof vis);
    int n;
    fn = 0;
    scanf("%d", &n);
    if (n == 1) {
      printf("! 1 1\n");
      fflush(stdout);
      continue;
    }
    vector<int> v;
    for (int i = 1; i < n; i += 2) {
      if (f(i, i + 1) == 2)
        v.push_back(i + 1), vis[i + 1] = 1;
      else
        v.push_back(i), vis[i] = 1;
    }
    int mn = v[0];
    int mx = n;
    vis[n] = 1;
    if (n & 1)
      v.push_back(n);
    else {
      if (v.back() == n) mx--;
      vis[mx] = 1;
    }
    for (int i = 1; i < int(v.size()); i++)
      if (f(mn, v[i])) mn = v[i];
    for (int i = 1; i < n; i++)
      if (!vis[i]) {
        if (!f(mx, i)) mx = i;
      }
    printf("! %d %d\n", mn, mx);
    fflush(stdout);
  }
  return 0;
}
