#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
long long int modInverse(long long int a) { return power(a, 1000000007 - 2); }
const int N = 500023;
bool vis[N];
vector<int> adj[N];
void solve() {
  long long int n;
  cin >> n;
  char ch;
  set<long long int> l, r;
  if (n == 1) {
    cout << '!' << ' ' << 1 << ' ' << 1 << endl;
    return;
  }
  for (int i = 1; i + 1 <= n; i += 2) {
    cout << '?' << ' ' << i << ' ' << i + 1 << endl;
    cin >> ch;
    if (ch == '>') {
      l.insert(i + 1);
      r.insert(i);
    } else {
      l.insert(i);
      r.insert(i + 1);
    }
  }
  if (n % 2 == 1) {
    l.insert(n);
    r.insert(n);
  }
  while (l.size() > 1) {
    auto it = l.begin();
    long long int indx1 = (*it);
    it++;
    long long int indx2 = (*it);
    cout << '?' << ' ' << indx1 << ' ' << indx2 << endl;
    cin >> ch;
    if (ch == '>')
      l.erase(indx1);
    else
      l.erase(indx2);
  }
  while (r.size() > 1) {
    auto it = r.begin();
    long long int indx1 = (*it);
    it++;
    long long int indx2 = (*it);
    cout << '?' << ' ' << indx1 << ' ' << indx2 << endl;
    cin >> ch;
    if (ch == '<')
      r.erase(indx1);
    else
      r.erase(indx2);
  }
  cout << '!' << ' ' << (*l.begin()) << ' ' << (*r.begin()) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  cin >> T;
  int t = 0;
  while (t++ < T) {
    solve();
  }
}
