#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 123;
const int mod = 1e9 + 7;
const long long inf = 1e18 + 9;
inline void boost() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
int n;
int f(int x) { return (3 * x + 1) / 2 - 2; }
char ask(int i, int j) {
  cout << "? " << i << ' ' << j << endl;
  char c;
  cin >> c;
  return c;
}
inline void solve() {
  cin >> n;
  if (n == 1) {
    cout << "! 1 1" << endl;
    return;
  }
  vector<int> mx, mn;
  for (int i = 1; i < n; i += 2) {
    char c = ask(i, i + 1);
    if (c == '>') {
      mx.push_back(i);
      mn.push_back(i + 1);
    } else {
      mx.push_back(i + 1);
      mn.push_back(i);
    }
  }
  if (n % 2 == 1) mx.push_back(n), mn.push_back(n);
  int pos = mx[0], pos1 = mn[0];
  for (int i = 1; i < (int)mx.size(); i++) {
    char c = ask(pos, mx[i]);
    if (c == '<') pos = mx[i];
  }
  for (int i = 1; i < (int)mn.size(); i++) {
    char c = ask(pos1, mn[i]);
    if (c == '>') pos1 = mn[i];
  }
  cout << "! " << pos1 << ' ' << pos << endl;
}
int main() {
  boost();
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
