#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 14;
bool ask(long long x) {
  cout << "? " << x << endl;
  bool r;
  cin >> r;
  return r;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long s = 0, d = 1;
    long long lo = 0, hi = n;
    while (hi - lo > 1) {
      long long mid = (lo + hi) / 2;
      s += d * mid;
      lo = mid;
      d = -d;
    }
    if (s < 0)
      s = n + s, d = -1;
    else
      s = n - s, d = 1;
    lo = 0, hi = n;
    ask(s);
    while (hi - lo > 1) {
      long long mid = (lo + hi) / 2;
      s += d * mid;
      if (ask(s))
        hi = mid;
      else
        lo = mid;
      d = -d;
    }
    cout << "= " << hi << endl;
  }
}
