#include <bits/stdc++.h>
using namespace std;
map<long long, bool> used;
int ask(long long i) {
  used[i] = 1;
  cout << "? " << i << endl;
  int x;
  cin >> x;
  return x;
}
void solve(long long n) {
  used.clear();
  long long l = 1, r = n;
  vector<long long> im;
  long long l1 = l, r1 = r;
  while (l1 < r1) {
    long long mid = (l1 + r1) / 2;
    im.push_back(mid);
    l1 = mid + 1;
  }
  reverse(im.begin(), im.end());
  long long curr = 1;
  for (int i = 0; i < im.size(); i++) {
    if (i & 1)
      curr -= im[i];
    else
      curr += im[i];
  }
  ask(curr);
  while (l < r) {
    long long mid = (l + r) / 2;
    if (curr + mid <= n && !used[curr + mid]) {
      curr += mid;
      if (ask(curr) == 0)
        l = mid + 1;
      else
        r = mid;
    } else if (curr - mid >= 1 && !used[curr - mid]) {
      curr -= mid;
      if (ask(curr) == 0)
        l = mid + 1;
      else
        r = mid;
    } else {
      l1 = l, r1 = r;
      im.clear();
      while (l1 < r1) {
        long long mid = (l1 + r1) / 2;
        im.push_back(mid);
        l1 = mid + 1;
      }
      reverse(im.begin(), im.end());
      curr = 1;
      for (int i = 0; i < im.size(); i++) {
        if (i & 1)
          curr -= im[i];
        else
          curr += im[i];
      }
      if (curr >= r + 1 - curr) curr = r + 1 - curr;
      curr = rand() % curr + 1;
      while (used[curr] || used[curr + mid] || used[curr - mid]) ++curr;
      ask(curr);
    }
  }
  cout << "= " << l << endl;
}
int main() {
  srand(69420);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    solve(n);
  }
  return 0;
}
