#include <bits/stdc++.h>
using namespace std;
const int Maxn = 66;
int t, a[Maxn], max_num, min_num, n;
char ch;
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    min_num = 0, max_num = 0;
    cin >> n;
    for (int i = 1; i <= n / 2; ++i) {
      cout << "? " << i * 2 - 1 << " " << i * 2 << '\n';
      cin >> ch;
      if (ch == '>' || ch == '=')
        a[i * 2 - 1] = 1, a[i * 2] = 0, min_num = i * 2, max_num = i * 2 - 1;
      if (ch == '<')
        a[i * 2] = 1, a[i * 2 - 1] = 0, max_num = i * 2, min_num = i * 2 - 1;
    }
    if (n % 2) a[n] = 2, min_num = n, max_num = n;
    for (int i = (n % 2) ? n - 1 : n - 2; i > 0; --i) {
      if (!a[i]) {
        cout << "? " << i << " " << min_num << '\n';
        cin >> ch;
        if (ch == '<') min_num = i;
      } else {
        cout << "? " << i << " " << max_num << '\n';
        cin >> ch;
        if (ch == '>') max_num = i;
      }
    }
    cout << "! " << min_num << " " << max_num << '\n';
  }
  return 0;
}
