#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, bool> vetor;
set<long long> chosen;
void c_stack(stack<long long>& s) {
  while (!s.empty()) s.pop();
}
vetor optimal_start(long long N) {
  stack<long long> steps;
  c_stack(steps);
  long long i = 1, j = N;
  while (j > i) {
    long long mid = (i + j) >> 1;
    steps.push(mid);
    i = mid + 1;
  }
  bool rightwise = true;
  long long current = 1;
  while (!steps.empty()) {
    long long now_ = steps.top();
    steps.pop();
    if (rightwise)
      current += now_;
    else
      current -= now_;
    rightwise = !rightwise;
  }
  return {current, rightwise};
}
vetor aproximation(long long past, long long target, long long mid,
                   long long N) {
  if (chosen.find(target) == chosen.end() && target > past && 1 <= target &&
      target <= N)
    return {target, true};
  if (chosen.find(target) == chosen.end() && target < past && 1 <= target &&
      target <= N)
    return {target, false};
  long long increases = max(target, (long long)1), decreases = min(target, N);
  while (increases <= N && chosen.find(increases) != chosen.end()) increases++;
  while (decreases >= 1 && chosen.find(decreases) != chosen.end()) decreases--;
  if (decreases < 1 && increases > past) return {increases, true};
  if (decreases < 1 && increases < past) return {increases, false};
  if (increases > N && decreases > past) return {decreases, true};
  if (increases > N && decreases < past) return {decreases, false};
  long long dif_inc = max(increases - past, past - increases),
            dif_dec = max(decreases - past, past - decreases);
  if (max(dif_inc - mid, mid - dif_inc) < max(dif_dec - mid, mid - dif_dec)) {
    if (increases > past)
      return {increases, true};
    else
      return {increases, false};
  } else {
    if (decreases > past)
      return {decreases, true};
    else
      return {decreases, false};
  }
}
void solve() {
  chosen.clear();
  long long N;
  cin >> N;
  vetor vet = optimal_start(N);
  cout << "? " << vet.first << endl;
  chosen.insert(vet.first);
  int _;
  cin >> _;
  long long i = 1, j = N;
  while (i < j) {
    long long mdl = (i + j) >> 1;
    long long targ;
    if (vet.second)
      targ = mdl + vet.first;
    else
      targ = vet.first - mdl;
    vetor aux = aproximation(vet.first, targ, mdl, N);
    long long actual = max(vet.first - aux.first, aux.first - vet.first);
    vet = aux;
    vet.second = !vet.second;
    cout << "? " << vet.first << endl;
    chosen.insert(vet.first);
    int ans;
    cin >> ans;
    if (actual < i || actual > j) continue;
    if (ans)
      j = actual;
    else
      i = actual + 1;
  }
  cout << "= " << i << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
