#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    char w;
    string min, max;
    int n, k = 0;
    cin >> n;
    if (n == 1)
      cout << "! 1 1"
           << "\n";
    else {
      for (int i = 1; 2 * i <= n; i++) {
        cout << "? " << 2 * i - 1 << " " << 2 * i << "\n";
        cin >> w;
        if (w == '<') {
          min += char(2 * i - 1 + 64);
          max += char(2 * i + 64);
        } else {
          max += char(2 * i - 1 + 64);
          min += char(2 * i + 64);
        }
      }
      while (min.length() > 1 || max.length() > 1) {
        for (int i = 0; 2 * i + 1 < min.length(); i++) {
          cout << "? " << min[2 * i] - 64 << " " << min[2 * i + 1] - 64 << "\n";
          cin >> w;
          if (w == '>' || w == '=') {
            min.erase(min.begin() + 2 * i);
          } else {
            min.erase(min.begin() + 2 * i + 1);
          }
        }
        for (int i = 0; 2 * i + 1 < max.length(); i++) {
          cout << "? " << max[2 * i] - 64 << " " << max[2 * i + 1] - 64 << "\n";
          cin >> w;
          if (w == '>' || w == '=') {
            max.erase(max.begin() + 2 * i + 1);
          } else {
            max.erase(max.begin() + 2 * i);
          }
        }
      }
      if (n % 2 == 0)
        cout << "! " << min[0] - 64 << " " << max[0] - 64;
      else {
        cout << "? " << max[0] - 64 << " " << n << "\n";
        cin >> w;
        if (w == '<')
          cout << "! " << min[0] - 64 << " " << n;
        else {
          cout << "? " << min[0] - 64 << " " << n << "\n";
          cin >> w;
          if (w == '>' || w == '=')
            cout << "! " << n << " " << max[0] - 64;
          else
            cout << "! " << min[0] - 64 << " " << max[0] - 64;
        }
      }
      cout << "\n";
    }
  }
}
