#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, x, y;
  cin >> t;
  while (t--) {
    long long n, i;
    cin >> n;
    vector<long long> a, b, c;
    for (i = 1; i <= n; i++) a.push_back(i);
    while (a.size() > 1) {
      x = a.back();
      a.pop_back();
      y = a.back();
      a.pop_back();
      cout << '?' << " " << x << " " << y << endl;
      fflush(stdout);
      char d;
      cin >> d;
      if (d == '=')
        a.push_back(x);
      else {
        if (d == '>') swap(x, y);
        b.push_back(x);
        c.push_back(y);
      }
    }
    if (!a.empty()) {
      b.push_back(a.back());
      c.push_back(a.back());
    }
    while (b.size() > 1) {
      x = b.back();
      b.pop_back();
      y = b.back();
      b.pop_back();
      cout << '?' << " " << x << " " << y << endl;
      fflush(stdout);
      char d;
      cin >> d;
      if (d == '>')
        b.push_back(y);
      else
        b.push_back(x);
    }
    while (c.size() > 1) {
      x = c.back();
      c.pop_back();
      y = c.back();
      c.pop_back();
      cout << '?' << " " << x << " " << y << endl;
      fflush(stdout);
      char d;
      cin >> d;
      if (d == '<')
        c.push_back(y);
      else
        c.push_back(x);
    }
    cout << '!' << " " << b.back() << " " << c.back() << endl;
    fflush(stdout);
  }
}
