#include <bits/stdc++.h>
using namespace std;
void debug() { cout << endl; }
template <class T, class... U>
void debug(T a, U... b) {
  cout << a << " ";
  debug(b...);
}
template <class T>
void pary(T l, T r) {
  while (l != r) {
    cout << *l << " ";
    l++;
  }
  cout << endl;
}
bool test = 0;
long long prvpos = 0, testc = 0;
bool query(long long pos) {
  cout << "? " << pos << endl;
  if (test) {
    bool ret = abs(pos - prvpos) >= testc;
    prvpos = pos;
    return ret;
  } else {
    int res;
    cin >> res;
    return res;
  }
}
long long get_start(long long n) {
  int dir = 1;
  long long cur = 0, ret = n, tot = n, sum = 0;
  while (n > 1) {
    cur += dir * (sum + (n >> 1));
    sum += n >> 1;
    dir *= -1;
    ret = min(ret, tot - cur);
    n -= n >> 1;
  }
  return ret;
}
long long solve(long long n, long long st, int dir, long long inc) {
  if (n == 2) {
    return inc + (query(st + (inc + 1) * dir) ? 1 : 2);
  } else if (n == 3) {
    bool v1 = query(st + (inc + 1) * dir);
    st += (inc + 1) * dir;
    dir *= -1;
    if (v1) return inc + 1;
    bool v2 = query(st + (inc + 2) * dir);
    return inc + (v2 ? 2 : 3);
  } else {
    long long pnt = st + (inc + (n >> 1)) * dir;
    if (query(pnt) == 0) {
      return solve((n + 1) / 2, pnt, -dir, inc + (n >> 1));
    } else {
      return solve(n / 2, pnt, -dir, inc);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    if (test) {
      cin >> testc;
      prvpos = 0;
    }
    long long st = get_start(n);
    query(st);
    long long ans = solve(n, st, 1, 0);
    cout << "= " << ans << endl;
  }
}
