#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 3e5;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (n == 1) {
      cout << "! " << 1 << " " << 1 << endl;
      continue;
    }
    queue<pair<int, int>> q;
    int m = n;
    while (m > 1) {
      cout << "? " << m - 1 << " " << m << endl;
      string x;
      cin >> x;
      if (x == "<") {
        q.push(make_pair(m - 1, m));
      } else if (x == ">") {
        q.push(make_pair(m, m - 1));
      } else {
        q.push(make_pair(m, m - 1));
      }
      m -= 2;
    }
    if (m == 1) {
      q.push(make_pair(1, 1));
    }
    while (q.size() > 1) {
      pair<int, int> a = q.front();
      q.pop();
      pair<int, int> b = q.front();
      q.pop();
      cout << "? " << a.first << " " << b.first << endl;
      string x;
      cin >> x;
      int maxi, mini;
      if (x == "<") {
        mini = a.first;
      } else if (x == ">") {
        mini = b.first;
      } else {
        mini = b.first;
      }
      cout << "? " << a.second << " " << b.second << endl;
      cin >> x;
      if (x == "<") {
        maxi = b.second;
      } else if (x == ">") {
        maxi = a.second;
      } else {
        maxi = a.second;
      }
      q.push(make_pair(mini, maxi));
    }
    pair<int, int> finalans = q.front();
    cout << "! " << finalans.first << " " << finalans.second << endl;
  }
  return 0;
}
