#include <bits/stdc++.h>
using namespace std;
char query(int i1, int i2) {
  cout << "? " << i1 << " " << i2 << endl;
  char ch;
  cin >> ch;
  return ch;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v1, v2;
    for (int i = 1; i <= n / 2; i++) {
      char ch = query(2 * i - 1, 2 * i);
      if (ch != '>') {
        v1.push_back(2 * i - 1);
        v2.push_back(2 * i);
      } else {
        v1.push_back(2 * i);
        v2.push_back(2 * i - 1);
      }
    }
    if (n & 1) v1.push_back(n), v2.push_back(n);
    int i1 = v1[0], i2 = v2[0];
    for (int i = 1; i <= (int)(v1).size() - 1; i++) {
      if (query(i1, v1[i]) == '>') i1 = v1[i];
    }
    for (int i = 1; i <= (int)(v2).size() - 1; i++) {
      if (query(i2, v2[i]) == '<') i2 = v2[i];
    }
    cout << "! " << i1 << " " << i2 << endl;
  }
  return 0;
}
