#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
bool ask(long long x) {
  cout << "? " << x << endl;
  bool ret;
  cin >> ret;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  int tc;
  cin >> tc;
  while (tc--) {
    long long n;
    cin >> n;
    long long lo = 0, hi = n;
    vector<long long> a;
    while (hi - lo > 1) {
      long long m = (lo + hi) >> 1;
      a.push_back(m);
      lo = m;
    }
    long long sum = 0;
    for (int i = 0; i < a.size(); i++)
      if (i & 1)
        sum -= a[i];
      else
        sum += a[i];
    long long now;
    if (sum < 0)
      now = -sum + 1;
    else
      now = n - sum;
    ask(now);
    int sign = 1;
    lo = 0, hi = n;
    while (hi - lo > 1) {
      long long mid = (lo + hi) >> 1;
      now += mid * sign;
      if (ask(now) == 0)
        lo = mid;
      else
        hi = mid;
      sign *= -1;
    }
    cout << "= " << hi << endl;
  }
}
