#include <bits/stdc++.h>
using namespace std;
long long questions;
long long n;
long long divUp(long long a, long long b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
char ask(long long i, long long j) {
  cout << "? " << i << " " << j << endl;
  char c;
  cin >> c;
  questions++;
  assert(questions <= divUp(3 * n, 2) - 2);
  return c;
}
void solve() {
  questions = 0;
  cin >> n;
  vector<pair<long long, long long>> v;
  for (int i = 2; i <= n; i += 2) {
    char c = ask(i - 1, i);
    if (c == '<') {
      v.push_back({i - 1, i});
    } else {
      v.push_back({i, i - 1});
    }
  }
  if (n % 2 == 1) {
    v.push_back({n, n});
  }
  pair<long long, long long> ans = v[0];
  for (int i = 1; i < v.size(); i++) {
    char cMin = ask(ans.first, v[i].first);
    if (cMin == '>') {
      ans.first = v[i].first;
    }
    char cMax = ask(ans.second, v[i].second);
    if (cMax == '<') {
      ans.second = v[i].second;
    }
  }
  cout << "! " << ans.first << " " << ans.second << endl;
}
int main() {
  long long T;
  cin >> T;
  for (int t = 0; t < T; t++) {
    solve();
  }
  return 0;
}
