#include <bits/stdc++.h>
using namespace std;
const int maxN = 55;
int n, a[maxN];
int findMin(int *a, int len) {
  if (len == 1) return a[0];
  int tmp = len / 2, mi;
  char op[5];
  for (int i = 0; i < tmp; ++i) {
    cout << "? " << a[i] << " " << a[tmp + i] << endl;
    fflush(stdout);
    scanf("%s", op);
    if (op[0] == '>') swap(a[i], a[tmp + i]);
  }
  mi = findMin(a, tmp);
  if (len % 2) {
    cout << "? " << mi << " " << a[len - 1] << endl;
    fflush(stdout);
    scanf("%s", op);
    if (op[0] == '>') mi = a[len - 1];
  }
  return mi;
}
int findMax(int *a, int len) {
  if (len == 1) return a[0];
  int tmp = len / 2, ma;
  char op[5];
  for (int i = 0; i < tmp; ++i) {
    cout << "? " << a[i] << " " << a[tmp + i] << endl;
    fflush(stdout);
    scanf("%s", op);
    if (op[0] == '>') swap(a[i], a[tmp + i]);
  }
  ma = findMax(a + tmp, tmp);
  if (len % 2) {
    cout << "? " << ma << " " << a[len - 1] << endl;
    fflush(stdout);
    scanf("%s", op);
    if (op[0] == '<') ma = a[len - 1];
  }
  return ma;
}
void work() {
  if (n == 1) {
    cout << "! " << 1 << " " << 1 << endl;
    return;
  }
  int tmp = n / 2, mi, ma;
  char op[5];
  for (int i = 0; i < tmp; ++i) {
    cout << "? " << a[i] << " " << a[tmp + i] << endl;
    fflush(stdout);
    scanf("%s", op);
    if (op[0] == '>') swap(a[i], a[tmp + i]);
  }
  mi = findMin(a, tmp);
  ma = findMax(a + tmp, tmp);
  if (n % 2) {
    cout << "? " << mi << " " << a[n - 1] << endl;
    fflush(stdout);
    scanf("%s", op);
    if (op[0] == '>') mi = a[n - 1];
    cout << "? " << ma << " " << a[n - 1] << endl;
    fflush(stdout);
    scanf("%s", op);
    if (op[0] == '<') ma = a[n - 1];
  }
  cout << "! " << mi << " " << ma << endl;
  fflush(stdout);
}
void input() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) a[i] = i + 1;
}
int main() {
  int T;
  scanf("%d", &T);
  for (int times = 1; times <= T; ++times) {
    input();
    work();
  }
  return 0;
}
