#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    vector<int> sml, big;
    for (int i = 1, j = n; i < j; i++, j--) {
      printf("? %d %d\n", i, j);
      fflush(stdout);
      char c[5];
      scanf("%s", c);
      if (c[0] == '<') {
        sml.push_back(i);
        big.push_back(j);
      }
      if (c[0] == '>') {
        sml.push_back(j);
        big.push_back(i);
      }
      if (c[0] == '=') {
        sml.push_back(i);
        big.push_back(j);
      }
    }
    if (n % 2) {
      big.push_back(ceil(n / 2.0));
      sml.push_back(ceil(n / 2.0));
    }
    int mn = sml[0];
    for (int i = 1; i < sml.size(); i++) {
      printf("? %d %d\n", mn, sml[i]);
      fflush(stdout);
      char c[5];
      scanf("%s", c);
      if (c[0] == '>') {
        mn = sml[i];
      }
    }
    int mx = big[0];
    for (int i = 1; i < big.size(); i++) {
      printf("? %d %d\n", mx, big[i]);
      fflush(stdout);
      char c[5];
      scanf("%s", c);
      if (c[0] == '<') {
        mx = big[i];
      }
    }
    printf("! %d %d\n", mn, mx);
    fflush(stdout);
  }
}
