#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000007LL;
const int N = 2e5 + 10;
const long long Inf = 2242545357980376863LL;
const long long Log = 30;
int Ask(long long P) {
  cout << "? " << P << endl;
  int res;
  cin >> res;
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    long long l = 0, r = n, mid;
    vector<long long> V;
    while (l + 1 < r) {
      mid = (l + r) >> 1;
      V.push_back(mid);
      l = mid;
    }
    reverse(V.begin(), V.end());
    long long z = -1;
    long long st = n;
    for (auto x : V) {
      st += z * x;
      z *= -1;
    }
    Ask(st);
    long long la = st;
    l = 0, r = n;
    while (l + 1 < r) {
      mid = (l + r) >> 1;
      if (Ask(la + z * mid))
        r = mid;
      else
        l = mid;
      la = la + z * mid;
      z *= -1;
    }
    cout << "= " << r << endl;
  }
  return 0;
}
