#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, maxi, mini;
    char c;
    cin >> n;
    vector<int> win, lose;
    for (int i = 1; i < n; i += 2) {
      cout << "? " << i << " " << i + 1 << endl;
      cin >> c;
      if (c == '>') {
        win.push_back(i);
        lose.push_back(i + 1);
      } else {
        win.push_back(i + 1);
        lose.push_back(i);
      }
    }
    if (n % 2 == 1) {
      win.push_back(n);
      lose.push_back(n);
    }
    while (win.size() >= 2) {
      vector<int> a;
      for (int i = 0; i < win.size() - 1; i += 2) {
        cout << "? " << win[i] << " " << win[i + 1] << endl;
        cin >> c;
        if (c == '>')
          a.push_back(win[i]);
        else
          a.push_back(win[i + 1]);
      }
      if (win.size() % 2 == 1) a.push_back(win.back());
      win = a;
    }
    maxi = win[0];
    while (lose.size() >= 2) {
      vector<int> a;
      for (int i = 0; i < lose.size() - 1; i += 2) {
        cout << "? " << lose[i] << " " << lose[i + 1] << endl;
        cin >> c;
        if (c == '<' || c == '=')
          a.push_back(lose[i]);
        else
          a.push_back(lose[i + 1]);
      }
      if (lose.size() % 2 == 1) a.push_back(lose.back());
      lose = a;
    }
    mini = lose[0];
    cout << "! " << mini << " " << maxi << endl;
  }
  return 0;
}
