#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6, M = 1e3, P = 31, MOD = 1e9 + 7, INF = 1e9, XMAX = 1e3;
void solve() {
  long long n;
  cin >> n;
  long long l = 0, r = n;
  long long start = 0;
  long long sea = n / 2;
  bool pl = 0;
  while (r - sea > 1) {
    if (pl)
      start += sea;
    else
      start -= sea;
    sea = (sea + r) / 2;
    pl = !pl;
  }
  if (start < 0)
    start = -start + 1;
  else
    start = n - start;
  cout << "? " << start << endl;
  long long res = 0;
  cin >> res;
  bool forward = 0;
  long long pos = start;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    if (forward)
      pos += mid;
    else
      pos -= mid;
    cout << "? " << pos << endl;
    cin >> res;
    if (res)
      r = mid;
    else
      l = mid;
    forward = !forward;
  }
  cout << "= " << r << endl;
}
int32_t main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
