#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long mod = 1e9 + 7;
signed main() {
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n;
    cin >> n;
    if (n == 1) {
      cout << "! " << 1 << ' ' << 1 << endl;
      continue;
    }
    vector<long long> mi, ma;
    mi.clear(), ma.clear();
    long long i, j;
    char ch;
    for (i = 1; i < n; i += 2) {
      cout << "? " << i << ' ' << i + 1 << endl;
      cin >> ch;
      if (ch == '>')
        mi.push_back(i + 1), ma.push_back(i);
      else
        mi.push_back(i), ma.push_back(i + 1);
    }
    if (i == n) {
      cout << "? " << mi[mi.size() - 1] << ' ' << i << endl;
      cin >> ch;
      if (ch == '>') {
        mi.pop_back();
        mi.push_back(i);
      } else if (ch == '<')
        ma.push_back(i);
    }
    long long minn = mi[0], maxx = ma[0], szmi = mi.size(), szma = ma.size();
    for (i = 1; i < szmi; ++i) {
      cout << "? " << minn << ' ' << mi[i] << endl;
      cin >> ch;
      if (ch == '>') minn = mi[i];
    }
    for (i = 1; i < szma; ++i) {
      cout << "? " << maxx << ' ' << ma[i] << endl;
      cin >> ch;
      if (ch == '<') maxx = ma[i];
    }
    cout << "! " << minn << ' ' << maxx << endl;
  }
  return 0;
}
