#include <bits/stdc++.h>
using namespace std;
int ask(long long x) {
  printf("? %lld\n", x);
  fflush(stdout);
  int y;
  cin >> y;
  return y;
}
void solve() {
  long long n;
  scanf("%lld", &n);
  int res;
  long long l = 0;
  long long r = n;
  int dir = 1;
  long long s = 0;
  while (r - l > 1) {
    long long mid = (l + r) >> 1;
    s = s + dir * mid;
    dir = -dir;
    l = mid;
  }
  long long cur = 0;
  if (s < 0)
    cur = -s + 1;
  else
    cur = n - s;
  assert(1 <= cur && cur <= n);
  ask(cur);
  l = 0;
  r = n;
  dir = 1;
  while (r - l > 1) {
    long long mid = (l + r) >> 1;
    cur += dir * mid;
    dir = -dir;
    res = ask(cur);
    if (res == 0) {
      l = mid;
    } else {
      r = mid;
    }
  }
  printf("= %lld\n", r);
  fflush(stdout);
}
int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    solve();
  }
}
