#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first - a.second) > (b.first - b.second);
}
std::vector<int> mx, mn;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    mn.clear();
    mx.clear();
    int n;
    cin >> n;
    cout << endl;
    for (int i = 1; i < n; i += 2) {
      cout << "? " << i << " " << i + 1 << endl;
      char a;
      cin >> a;
      if (a == '>') {
        mx.push_back(i);
        mn.push_back(i + 1);
      } else {
        mx.push_back(i + 1);
        mn.push_back(i);
      }
    }
    if (n % 2) {
      mn.push_back(n);
      mx.push_back(n);
    }
    int mini = mn[0], maxi = mx[0];
    for (int i = 1; i < mn.size(); i++) {
      cout << "? " << mini << " " << mn[i] << endl;
      char a;
      cin >> a;
      if (a == '>') mini = mn[i];
    }
    for (int i = 1; i < mx.size(); i++) {
      cout << "? " << maxi << " " << mx[i] << endl;
      char a;
      cin >> a;
      if (a == '<') maxi = mx[i];
    }
    cout << "! " << mini << " " << maxi << endl;
  }
  return 0;
}
