#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int N = 101;
int _, n, mx[N], mn[N];
string res;
int main() {
  for (cin >> _; _; _--) {
    cin >> n;
    for (int i = 0; i < n; i += 2) {
      mx[i / 2] = mn[i / 2] = i + 1;
      if (i + 1 < n) {
        cout << "? " << i + 1 << " " << i + 2 << endl;
        cin >> res;
        if (res == ">")
          mx[i / 2] = i + 1, mn[i / 2] = i + 2;
        else if (res == "<")
          mx[i / 2] = i + 2, mn[i / 2] = i + 1;
      }
    }
    n = (n + 1) / 2;
    int max_ans = mx[0], min_ans = mn[0];
    for (int i = (1); i < (n); i++) {
      cout << "? " << max_ans << " " << mx[i] << endl;
      cin >> res;
      if (res == "<") max_ans = mx[i];
    }
    for (int i = (1); i < (n); i++) {
      cout << "? " << min_ans << " " << mn[i] << endl;
      cin >> res;
      if (res == ">") min_ans = mn[i];
    }
    cout << "! " << min_ans << " " << max_ans << endl;
  }
}
