#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int w = 1, c = 0;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') w = -1;
  for (; isdigit(ch); ch = getchar()) c = (c << 1) + (c << 3) + (ch ^ 48);
  return w * c;
}
bool qry(long long x) {
  cout << "? " << x << endl;
  bool tmp;
  cin >> tmp;
  return tmp;
}
long long n;
int main() {
  int T = read();
  while (T--) {
    cin >> n;
    long long l = 1, r = n - 1, delta = 0, p0 = n;
    bool st = 0;
    while (l <= r) {
      long long mid = (l + r >> 1);
      if (st)
        delta -= mid;
      else
        delta += mid;
      p0 = min(n - delta, p0);
      l = mid + 1;
      st ^= 1;
    }
    qry(p0);
    long long p1 = p0, ans = n;
    l = 1;
    r = n - 1;
    st = 0;
    while (l <= r) {
      long long mid = (l + r >> 1);
      if (st)
        p1 = p0 - mid;
      else
        p1 = p0 + mid;
      if (qry(p1))
        r = mid - 1, ans = mid;
      else
        l = mid + 1;
      st ^= 1;
      p0 = p1;
    }
    cout << "= " << ans << endl;
  }
  return 0;
}
