#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
namespace input {
inline int nextInt() {
  int res = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res;
}
inline long long nextLong() {
  long long res = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res;
}
inline bool isSpace(const char &c) {
  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
inline void next(char *str) {
  char c = getchar();
  while (isSpace(c)) c = getchar();
  size_t head = 0;
  while (!isSpace(c)) str[head++] = c, c = getchar();
  str[head] = 0;
}
inline char nextChar() {
  char c = getchar();
  while (isSpace(c)) c = getchar();
  return c;
}
}  // namespace input
using namespace input;
const int N = 3e5 + 5;
int get(int i, int j) {
  printf("? %d %d\n", i, j);
  fflush(stdout);
  char c;
  scanf(" %c", &c);
  if (c == '>') {
    return 1;
  } else if (c == '<') {
    return -1;
  } else {
    return 0;
  }
}
void out(pair<int, int> ans) {
  printf("! %d %d\n", ans.second, ans.first);
  fflush(stdout);
}
void solve() {
  int n;
  scanf("%d", &n);
  if (n == 1) {
    printf("! 1 1\n");
    fflush(stdout);
    return;
  }
  vector<pair<int, int> > cur;
  for (int i = 0; i + 1 < n; i += 2) {
    int res = get(i + 1, i + 2);
    if (res == 1) {
      cur.push_back({i + 1, i + 2});
    } else if (res == -1) {
      cur.push_back({i + 2, i + 1});
    } else {
      cur.push_back({i + 1, i + 1});
    }
  }
  if (n & 1) {
    cur.push_back({n, n});
  }
  while (cur.size() != 1) {
    vector<pair<int, int> > temp;
    for (int i = 0; i + 1 < cur.size(); i += 2) {
      int res1 = get(cur[i].first, cur[i + 1].first);
      int cur_mx = 0;
      if (res1 == 1) {
        cur_mx = cur[i].first;
      } else if (res1 == -1) {
        cur_mx = cur[i + 1].first;
      } else {
        cur_mx = cur[i].first;
      }
      int res2 = get(cur[i].second, cur[i + 1].second);
      int cur_min = 0;
      if (res2 == -1) {
        cur_min = cur[i].second;
      } else if (res2 == 1) {
        cur_min = cur[i + 1].second;
      } else {
        cur_min = cur[i + 1].second;
      }
      temp.push_back({cur_mx, cur_min});
    }
    if (cur.size() & 1) {
      temp.push_back(cur.back());
    }
    cur = temp;
  }
  out(cur.back());
}
