#include <bits/stdc++.h>
using namespace std;
int maxl[50], minl[50];
int main() {
  int T, n;
  cin >> T;
  char cmp;
  while (T--) {
    cin >> n;
    int cntmax = 1, cntmin = 1;
    for (int i = 1; i <= n - 1; i += 2) {
      cout << "? " << i << ' ' << i + 1 << endl;
      cin >> cmp;
      if (cmp == '>')
        maxl[cntmax++] = i, minl[cntmin++] = i + 1;
      else
        maxl[cntmax++] = i + 1, minl[cntmin++] = i;
    }
    if (n & 1) maxl[cntmax++] = minl[cntmin++] = n;
    n = (++n) / 2;
    while (n ^ 1) {
      cntmax = cntmin = 1;
      for (int i = 1; i <= n - 1; i += 2) {
        cout << "? " << maxl[i] << ' ' << maxl[i + 1] << endl;
        cin >> cmp;
        if (cmp == '>')
          maxl[cntmax++] = maxl[i];
        else
          maxl[cntmax++] = maxl[i + 1];
        cout << "? " << minl[i] << ' ' << minl[i + 1] << endl;
        cin >> cmp;
        if (cmp == '<')
          minl[cntmin++] = minl[i];
        else
          minl[cntmin++] = minl[i + 1];
      }
      if (n & 1) maxl[cntmax++] = maxl[n], minl[cntmin++] = minl[n];
      n = (++n) / 2;
    }
    cout << "! " << minl[1] << ' ' << maxl[1] << endl;
  }
  return 0;
}
