#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chkmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using ll = long long;
using ld = long double;
const string FILENAME = "input";
bool ask(ll x) {
  cout << "? " << x << endl;
  int resp;
  cin >> resp;
  return resp;
}
void solve() {
  ll n;
  cin >> n;
  ll cur = 0;
  ll start = n;
  ll l = 1;
  ll r = n - 1;
  int g = 0;
  while (l <= r) {
    ll mid = (l + r) / 2;
    cur += (!g ? mid : -mid);
    chkmin(start, n - cur);
    l = mid + 1;
    g ^= 1;
  }
  l = 1;
  r = n - 1;
  g = 0;
  ll res = n;
  ask(start);
  while (l <= r) {
    ll mid = (l + r) / 2;
    ll nstart = start + (!g ? mid : -mid);
    if (ask(nstart)) {
      res = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
    start = nstart;
    g ^= 1;
  }
  cout << "= " << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
