#include <bits/stdc++.h>
using namespace std;
vector<int> graph[55];
int vis[55];
int main() {
  int t, i, n;
  cin >> t;
  while (t--) {
    scanf("%d", &n);
    string response;
    vector<int> larger, smaller;
    int i;
    for (i = 1; i < n; i += 2) {
      printf("? %d %d\n", i, i + 1);
      fflush(stdout);
      cin >> response;
      if (response == ">") {
        larger.push_back(i);
        smaller.push_back(i + 1);
      } else {
        larger.push_back(i + 1);
        smaller.push_back(i);
      }
    }
    if (i == n) {
      larger.push_back(n);
      smaller.push_back(n);
    }
    int largeindex = larger[0];
    for (unsigned int i = 1; i < larger.size(); i++) {
      printf("? %d %d\n", largeindex, larger[i]);
      fflush(stdout);
      cin >> response;
      if (response == "<") {
        largeindex = larger[i];
      }
    }
    int smallindex = smaller[0];
    for (int i = 1; i < smaller.size(); i++) {
      printf("? %d %d\n", smallindex, smaller[i]);
      fflush(stdout);
      cin >> response;
      if (response == ">") {
        smallindex = smaller[i];
      }
    }
    printf("! %d %d\n", smallindex, largeindex);
    fflush(stdout);
  }
  return 0;
}
