#include <bits/stdc++.h>
using namespace std;
const int maxn = 50 + 5;
struct node {
  int max_;
  int min_;
  node() : max_(0), min_(0) {}
  node(int a, int b) : max_(a), min_(b) {}
};
queue<node> q;
void init(int n) {
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; ++i) q.push(node(i, i));
}
int main(int argc, char const *argv[]) {
  int T;
  cin >> T;
  while (T--) {
    int n;
    node t1, t2, target;
    int tmp_max, tmp_min;
    cin >> n;
    char op;
    init(n);
    for (int i = 1; i <= (n % 2 == 0 ? n : n - 1); i += 2) {
      t1 = q.front();
      q.pop();
      t2 = q.front();
      q.pop();
      cout << "? " << t1.min_ << " " << t2.min_ << endl;
      cin >> op;
      if (op == '=')
        q.push(node(t1.min_, t1.min_));
      else if (op == '>')
        q.push(node(t1.min_, t2.min_));
      else if (op == '<')
        q.push(node(t2.min_, t1.min_));
    }
    while (q.size() > 1) {
      t1 = q.front();
      q.pop();
      t2 = q.front();
      q.pop();
      if (t1.max_ == t1.min_ && t2.max_ == t2.min_) {
        cout << "? " << t1.min_ << " " << t2.min_ << endl;
        cin >> op;
        if (op == '=')
          q.push(node(t1.min_, t1.min_));
        else if (op == '>')
          q.push(node(t1.min_, t2.min_));
        else if (op == '<')
          q.push(node(t2.min_, t1.min_));
        continue;
      }
      cout << "? " << t1.min_ << " " << t2.min_ << endl;
      cin >> op;
      if (op == '=') {
        tmp_min = t1.min_;
      } else if (op == '>') {
        tmp_min = t2.min_;
      } else if (op == '<') {
        tmp_min = t1.min_;
      }
      cout << "? " << t1.max_ << " " << t2.max_ << endl;
      cin >> op;
      if (op == '=') {
        tmp_max = t1.max_;
      } else if (op == '>') {
        tmp_max = t1.max_;
      } else if (op == '<') {
        tmp_max = t2.max_;
      }
      q.push(node(tmp_max, tmp_min));
    }
    node ans = q.front();
    cout << "! " << ans.min_ << " " << ans.max_ << endl;
  }
  return 0;
}
