#include <bits/stdc++.h>
using namespace std;
long long n;
int resp;
int ask(long long x) {
  printf("? %lld\n", x);
  fflush(stdout);
  scanf("%d", &resp);
  return resp;
}
void ans(long long x) {
  printf("= %lld\n", x);
  fflush(stdout);
}
void solve() {
  scanf("%lld", &n);
  if (n == 2ll) {
    resp = ask(1ll);
    resp = ask(2ll);
    if (resp)
      ans(1ll);
    else
      ans(2ll);
    return;
  } else if (n == 3ll) {
    resp = ask(2ll);
    resp = ask(1ll);
    if (resp)
      ans(1ll);
    else {
      resp = ask(3ll);
      if (resp)
        ans(2ll);
      else
        ans(3ll);
    }
    return;
  }
  vector<long long> path_mid_to_hi;
  long long lf = 1ll, rg = n - 1ll;
  for (long long md; lf <= rg;) {
    md = (lf + rg) / 2ll;
    path_mid_to_hi.push_back(md);
    if (lf == rg && md == n - 1ll) break;
    lf = md + 1ll;
  }
  long long st = n, bf = n;
  reverse(path_mid_to_hi.begin(), path_mid_to_hi.end());
  bool go_left = 1;
  for (long long i : path_mid_to_hi) {
    bf = st;
    if (go_left)
      st -= i;
    else
      st += i;
    go_left ^= 1;
  }
  if (bf < st)
    go_left = 1;
  else
    go_left = 0;
  lf = 1ll, rg = n - 1ll;
  long long res = n;
  resp = ask(st);
  for (long long md; lf <= rg;) {
    md = (lf + rg) / 2;
    if (go_left && st - md >= 1)
      st -= md;
    else
      st += md;
    resp = ask(st);
    if (resp) {
      res = md;
      rg = md - 1;
    } else
      lf = md + 1;
    go_left ^= 1;
  }
  ans(res);
  return;
}
int main() {
  int tc;
  scanf("%d", &tc);
  for (; tc--;) solve();
  return 0;
}
