#include <bits/stdc++.h>
using namespace std;
int n, t;
vector<int> mn, mx;
char ch;
int main() {
  cin >> t;
  while (t--) {
    mn.clear();
    mx.clear();
    cin >> n;
    if (n == 1) {
      cout << "! 1 1\n";
      fflush(stdout);
      continue;
    }
    for (int i = 1; i <= n; i += 2) {
      cout << "? ";
      fflush(stdout);
      cout << i << " ";
      fflush(stdout);
      cout << i + 1 << "\n";
      fflush(stdout);
      cin >> ch;
      if (ch == '<') {
        mn.push_back(i), mx.push_back(i + 1);
      } else
        mn.push_back(i + 1), mx.push_back(i);
      if (i + 2 >= n) break;
    }
    if (n % 2) mn.push_back(n), mx.push_back(n);
    int mnn = mn[0];
    for (int i = 1; i < mn.size(); i++) {
      cout << "? ";
      fflush(stdout);
      cout << mnn << " ";
      fflush(stdout);
      cout << mn[i] << "\n";
      fflush(stdout);
      cin >> ch;
      if (ch == '>') {
        mnn = mn[i];
      }
    }
    int mxx = mx[0];
    for (int i = 1; i < mx.size(); i++) {
      cout << "? ";
      fflush(stdout);
      cout << mxx << " ";
      fflush(stdout);
      cout << mx[i] << "\n";
      fflush(stdout);
      cin >> ch;
      if (ch == '<') {
        mxx = mx[i];
      }
    }
    cout << "! ";
    fflush(stdout);
    cout << mnn << " ";
    fflush(stdout);
    cout << mxx << "\n";
    fflush(stdout);
  }
}
