#include <bits/stdc++.h>
using namespace std;
long long N;
bool ask(long long n) {
  cout << "? " << n << endl;
  bool res;
  cin >> res;
  return res;
}
void solve() {
  cin >> N;
  long long l = 1;
  long long r = N - 1;
  long long delta = 0;
  long long start = N;
  bool t = false;
  while (l <= r) {
    long long m = (l + r) >> 1;
    delta += t ? -m : m;
    start = min(start, N - delta);
    l = m + 1;
    t = !t;
  }
  l = 1;
  r = N - 1;
  t = false;
  long long ans = N;
  ask(start);
  while (l <= r) {
    long long m = (l + r) >> 1;
    long long ns = start + (t ? -m : m);
    if (ask(ns)) {
      ans = m;
      r = m - 1;
    } else {
      l = m + 1;
    }
    t = !t;
    start = ns;
  }
  cout << "= " << ans << endl;
  return;
}
int main() {
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
