#include <bits/stdc++.h>
using namespace std;
int T, n, mi, ma, a, b, i;
char x;
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    if (n == 1) {
      cout << "! 1 1" << endl;
      continue;
    }
    cout << "? 1 2" << endl;
    cin >> x;
    mi = 1;
    ma = 2;
    if (x == '>') swap(mi, ma);
    for (i = 3; i + 1 <= n; i += 2) {
      a = i;
      b = i + 1;
      cout << "? " << a << " " << b << endl;
      cin >> x;
      if (x == '>') swap(a, b);
      cout << "? " << a << " " << mi << endl;
      cin >> x;
      if (x == '<') swap(a, mi);
      cout << "? " << b << " " << ma << endl;
      cin >> x;
      if (x == '>') swap(b, ma);
    }
    if (n % 2 == 1) {
      cout << "? " << n << " " << mi << endl;
      cin >> x;
      if (x == '<') mi = n;
      cout << "? " << n << " " << ma << endl;
      cin >> x;
      if (x == '>') ma = n;
    }
    cout << "! " << mi << " " << ma << endl;
  }
}
