#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> tmp, large, small;
char op[20];
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
char check(int i, int j) {
  fflush(stdout);
  scanf("%s", op);
  return op[0];
  if (a[i] == a[j]) return '=';
  return a[i] < a[j] ? '<' : '>';
}
void solve1() {
  int len;
  while (len = small.size(), len > 1) {
    tmp.clear();
    for (int i = 0; i < len - 1; i += 2) {
      printf("? %d %d\n", small[i], small[i + 1]);
      op[0] = check(small[i], small[i + 1]);
      if (op[0] == '>') {
        tmp.push_back(small[i + 1]);
      } else {
        tmp.push_back(small[i]);
      }
    }
    if (len & 1) {
      printf("? %d %d\n", tmp[0], small[len - 1]);
      op[0] = check(tmp[0], small[len - 1]);
      if (op[0] == '>') {
        tmp[0] = small[len - 1];
      }
    }
    small = tmp;
  }
}
void solve2() {
  int len;
  while (len = large.size(), len > 1) {
    tmp.clear();
    for (int i = 0; i < len - 1; i += 2) {
      printf("? %d %d\n", large[i], large[i + 1]);
      op[0] = check(large[i], large[i + 1]);
      if (op[0] == '<') {
        tmp.push_back(large[i + 1]);
      } else {
        tmp.push_back(large[i]);
      }
    }
    if (len & 1) {
      printf("? %d %d\n", tmp[0], large[len - 1]);
      op[0] = check(tmp[0], large[len - 1]);
      if (op[0] == '<') {
        tmp[0] = large[len - 1];
      }
    }
    large = tmp;
  }
}
int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    scanf("%d", &n);
    if (n == 1) {
      printf("! 1 1\n");
      fflush(stdout);
      continue;
    }
    large.clear();
    small.clear();
    for (int i = 1; i <= n; i += 2) {
      if (i + 1 <= n) {
        printf("? %d %d\n", i, i + 1);
        op[0] = check(i, i + 1);
        if (op[0] == '>') {
          large.push_back(i);
          small.push_back(i + 1);
        } else {
          large.push_back(i + 1);
          small.push_back(i);
        }
      }
    }
    if (n & 1) {
      printf("? %d %d\n", small[0], n);
      op[0] = check(small[0], n);
      if (op[0] == '>' || op[0] == '=') {
        small[0] = n;
      } else {
        large.push_back(n);
      }
    }
    solve1();
    solve2();
    printf("! %d %d\n", small[0], large[0]);
    fflush(stdout);
  }
  return 0;
}
