#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 0, n = 0, i = 0, min = 0, max = 0;
  char temp1;
  cin >> t;
  while (t--) {
    cin >> n;
    if (n == 1) {
      cout << "! 1 1" << endl;
      continue;
    }
    int mini[n / 2], maxa[n / 2];
    for (i = 0; i < n - 1; i += 2) {
      cout << "? " << i + 1 << " " << i + 2 << endl;
      fflush(stdout);
      cin >> temp1;
      switch (temp1) {
        case '=':
        case '<':
          mini[i / 2] = i;
          maxa[i / 2] = i + 1;
          break;
        case '>':
          mini[i / 2] = i + 1;
          maxa[i / 2] = i;
          break;
      }
    }
    min = 0;
    for (i = 0; i < n / 2 - 1; i++) {
      cout << "? " << mini[min] + 1 << " " << mini[i + 1] + 1 << endl;
      fflush(stdout);
      cin >> temp1;
      if (temp1 == '>') {
        min = i + 1;
      }
    }
    max = 0;
    for (i = 0; i < n / 2 - 1; i++) {
      cout << "? " << maxa[max] + 1 << " " << maxa[i + 1] + 1 << endl;
      fflush(stdout);
      cin >> temp1;
      if (temp1 == '<') {
        max = i + 1;
      }
    }
    min = mini[min];
    max = maxa[max];
    if (n % 2) {
      cout << "? " << min + 1 << " " << n << endl;
      fflush(stdout);
      cin >> temp1;
      if (temp1 == '>') {
        min = n - 1;
      }
      cout << "? " << max + 1 << " " << n << endl;
      fflush(stdout);
      cin >> temp1;
      if (temp1 == '<') {
        max = n - 1;
      }
    }
    cout << "! " << min + 1 << " " << max + 1 << endl;
  }
  return 0;
}
