#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T, n;
  cin >> T;
  while (T--) {
    cin >> n;
    if (n == 1) {
      cout << "! 1 1\n";
      cout.flush();
      continue;
    }
    vector<int> a, b;
    for (int i = 1; i < n; i += 2) {
      cout << "? " << i << ' ' << i + 1 << '\n';
      cout.flush();
      char ans;
      cin >> ans;
      if (ans == '<') {
        a.push_back(i);
        b.push_back(i + 1);
      } else {
        b.push_back(i);
        a.push_back(i + 1);
      }
    }
    if (n & 1) {
      a.push_back(n);
      b.push_back(n);
    }
    int ans = a[0];
    for (int i = 1; i < (int)a.size(); ++i) {
      cout << "? " << ans << ' ' << a[i] << '\n';
      cout.flush();
      char rez;
      cin >> rez;
      if (rez == '>') ans = a[i];
    }
    int anss = b[0];
    for (int i = 1; i < (int)b.size(); ++i) {
      cout << "? " << anss << ' ' << b[i] << '\n';
      cout.flush();
      char rez;
      cin >> rez;
      if (rez == '<') anss = b[i];
    }
    cout << "! " << ans << ' ' << anss << '\n';
    cout.flush();
  }
  return 0;
}
