#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && (c != '-')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
inline bool check(long long L, long long n) {
  long long l = 1, r = n - 1, f = 1;
  while (l <= r) {
    long long mid = l + r >> 1;
    L += mid * f, f *= -1;
    if (L < 1 || L > n) return 0;
    l = mid + 1;
  }
  return 1;
}
inline long long Get(long long l, long long r, long long n) {
  for (long long i = l; i <= r; i++)
    if (check(i, n)) return i;
}
long long las, c, _n;
inline int Query(long long x) {
  cout << "? " << x << endl;
  return read();
}
inline void Answer(long long x) { cout << "= " << x << endl; }
inline void solve() {
  long long n = read();
  long long l = 1, r = n - 1, f = 0, L = 0, ans = n;
  while (l <= r) {
    long long mid = l + r >> 1;
    L += f * (mid - l + 1), f ^= 1, l = mid + 1;
  }
  L = Get(max(1ll, L - 10), min(L + 10, n), n);
  l = 1, r = n - 1, Query(L), f = 1;
  while (l <= r) {
    long long mid = l + r >> 1;
    L += mid * f, f *= -1;
    if (Query(L))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  Answer(ans);
}
int main() {
  int T = read();
  while (T--) solve();
}
