#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216") ﻿
using namespace std;
using ll = long long;
using ull = unsigned long long;
using intpair = pair<int, int>;
using llpair = pair<ll, ll>;
using ld = long double;
using vint = vector<int>;
ll N, M, K;
string S, T;
char cmp(int i, int j) {
  cout << "? " << i << " " << j << endl;
  char ans;
  cin >> ans;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> M;
    vint mins, maxs;
    mins.reserve(M);
    maxs.reserve(M);
    for (int i = 1; i <= M; i += 2) {
      if (i + 1 > M) {
        mins.push_back(M);
        maxs.push_back(M);
        break;
      }
      switch (cmp(i, i + 1)) {
        case '=':
        case '<':
          mins.push_back(i);
          maxs.push_back(i + 1);
          break;
        case '>':
          maxs.push_back(i);
          mins.push_back(i + 1);
          break;
      }
    }
    int maxI = maxs[0], minI = mins[0];
    for (int i = 1; i < maxs.size(); ++i) {
      if (cmp(maxI, maxs[i]) == '<') maxI = maxs[i];
    }
    for (int i = 1; i < mins.size(); ++i) {
      if (cmp(minI, mins[i]) == '>') minI = mins[i];
    }
    cout << "! " << minI << " " << maxI << endl;
  }
  return 0;
}
