#include <bits/stdc++.h>
using namespace std;
inline void out(int a) { printf("%d\n", a); }
inline void out(int a, int b) { printf("%d %d\n", a, b); }
inline void outf(double a) { printf("%3.lf\n", a); }
inline void outf(double a, double b) { printf("%3.lf %3.lf\n", a, b); }
inline void base() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
}
int tour(vector<int> ls) {
  while (ls.size() != 1) {
    vector<int> nx;
    for (int i = 0; i < ls.size(); i += 2) {
      if (i + 1 == ls.size()) {
        nx.push_back(ls[i]);
        break;
      }
      cout << "? " << ls[i] << " " << ls[i + 1] << endl;
      char c;
      cin >> c;
      if (c == '>') {
        nx.push_back(ls[i]);
      } else if (c == '<') {
        nx.push_back(ls[i + 1]);
      } else if (c == '=') {
        nx.push_back(ls[i]);
      }
    }
    ls = nx;
  }
  return ls[0];
}
int tour1(vector<int> ls) {
  while (ls.size() != 1) {
    vector<int> nx;
    for (int i = 0; i < ls.size(); i += 2) {
      if (i + 1 == ls.size()) {
        nx.push_back(ls[i]);
        break;
      }
      cout << "? " << ls[i] << " " << ls[i + 1] << endl;
      char c;
      cin >> c;
      if (c == '>') {
        nx.push_back(ls[i + 1]);
      } else if (c == '<') {
        nx.push_back(ls[i]);
      } else if (c == '=') {
        nx.push_back(ls[i]);
      }
    }
    ls = nx;
  }
  return ls[0];
}
int main() {
  base();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    if (n == 1) {
      cout << "! 1 1" << endl;
      continue;
    }
    vector<int> lose;
    vector<int> win;
    for (int i = 1; i <= n; i += 2) {
      if (i + 1 <= n) {
        cout << "? " << i << " " << i + 1 << endl;
        char c;
        cin >> c;
        if (c == '>') {
          win.push_back(i);
          lose.push_back(i + 1);
        } else if (c == '<') {
          win.push_back(i + 1);
          lose.push_back(i);
        } else {
          win.push_back(i);
          lose.push_back(i);
        }
      } else {
        win.push_back(i);
        lose.push_back(i);
      }
    }
    int mx = tour(win), mn = tour1(lose);
    cout << "! " << mn << " " << mx << endl;
  }
  return 0;
}
