#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  auto calc_spos = [](ll N) {
    ll ok = N, ng = 0, i = 0, sign = 1;
    ll min_v = 1;
    while (abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
      i += mid * sign;
      ng = mid;
      sign *= -1;
      min_v = min(min_v, i);
    }
    return max(1ll, 1 - min_v);
  };
  int T;
  cin >> T;
  for (ll _ = 0, _Len = (T); _ < _Len; ++_) {
    ll N, resp;
    cin >> N;
    ll ok = N, ng = 0, sign = 1, i = calc_spos(N);
    cout << "? " << i << endl;
    cin >> resp;
    while (abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
      i += mid * sign;
      cout << "? " << i << endl;
      cin >> resp;
      if (resp)
        ok = mid;
      else
        ng = mid;
      sign *= -1;
    }
    cout << "= " << ok << endl;
  }
}
