#include <bits/stdc++.h>
using namespace std;
int cnt;
int ask(long long x) {
  cout << "? " << x << endl;
  int r;
  cin >> r;
  cnt++;
  return r;
}
void answer(long long x) { cout << "= " << x << endl; }
void solve() {
  cnt = 0;
  long long n;
  cin >> n;
  vector<long long> dist;
  long long l = 1, r = n - 1;
  while (l <= r) {
    long long mid = (l + r) / 2;
    dist.push_back(mid);
    if (l == r && mid == n - 1) break;
    l = mid + 1;
  }
  reverse(dist.begin(), dist.end());
  long long st = n, prv = n;
  for (long long i = 0; i < dist.size(); i++) {
    prv = st;
    if (i & 1)
      st += dist[i];
    else
      st -= dist[i];
  }
  bool rev = (prv < st);
  l = 1, r = n - 1;
  long long ans = n;
  ask(st);
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (rev)
      st -= mid;
    else
      st += mid;
    int c = ask(st);
    if (c) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
    rev ^= 1;
  }
  answer(ans);
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
