#include <bits/stdc++.h>
using namespace std;
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const set<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const multiset<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const map<T1, T2, T3>& v) {
  bool f = 1;
  os << "[";
  for (auto& ii : v) {
    if (!f) os << ", ";
    os << "(" << ii.first << " -> " << ii.second << ") ";
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const multimap<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& ii : v) {
    if (!f) os << ", ";
    os << "(" << ii.first << " -> " << ii.second << ") ";
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, priority_queue<T1, T2> v) {
  bool f = 1;
  os << "[";
  while (!v.empty()) {
    auto x = v.top();
    v.pop();
    if (!f) os << ", ";
    f = 0;
    os << x;
  }
  return os << "]";
}
template <class T1, class T2>
void printarray(const T1& a, T2 sz, T2 beg = 0) {
  for (T2 i = beg; i < sz; i++) cout << a[i] << " ";
  cout << endl;
}
void cio() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
}
const long long mod = 1e9 + 9;
void die() {
  printf("No\n");
  exit(0);
}
char ask(int x, int y) {
  printf("? %d %d\n", x, y);
  fflush(stdout);
  char ch[3];
  scanf("%s", ch);
  return ch[0];
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int N;
    scanf("%d", &N);
    vector<int> w, l;
    if (N % 2) w.push_back(N), l.push_back(N);
    for (int i = 1; i + 1 <= N; i += 2) {
      char c = ask(i, i + 1);
      if (c == '<')
        w.push_back(i + 1), l.push_back(i);
      else
        w.push_back(i), l.push_back(i + 1);
    }
    int ans[2] = {l[0], w[0]};
    for (int i = 1; i < (int)l.size(); i++) {
      char c = ask(ans[0], l[i]);
      if (c == '>') ans[0] = l[i];
    }
    for (int i = 1; i < (int)w.size(); i++) {
      char c = ask(ans[1], w[i]);
      if (c == '<') ans[1] = w[i];
    }
    printf("! %d %d\n", ans[0], ans[1]);
    fflush(stdout);
  }
  return 0;
}
