#include <bits/stdc++.h>
using namespace std;
long long base(long long n) {
  long long r = 0;
  long long pass = n, fail = 0;
  long long cur = 0, sign = 1;
  while (pass - fail > 1) {
    long long mid = (pass + fail) / 2;
    cur += mid * sign;
    r = min(r, cur);
    sign *= -1;
    fail = mid;
  }
  return r;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    auto query = [&](long long v) {
      cout << "? " << v << endl;
      int ans;
      cin >> ans;
      return ans;
    };
    long long pass = n, fail = 0;
    long long cur = 1 - base(n);
    query(cur);
    long long sign = 1;
    while (pass - fail > 1) {
      long long mid = (pass + fail) / 2;
      cur += mid * sign;
      sign *= -1;
      if (query(cur))
        pass = mid;
      else
        fail = mid;
    }
    cout << "= " << pass << endl;
  }
}
