#include <bits/stdc++.h>
using namespace std;
int T;
long long n;
inline void query(long long x) { cout << "? " << x << endl; }
inline bool check(long long s) {
  if (s < 1 || s > n) return 0;
  int op = 1;
  long long l = 1, r = n - 1;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    s += op * mid;
    op *= -1;
    if (s < 1 || s > n) return 0;
    l = mid + 1;
  }
  return 1;
}
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    long long l = 1, r = n - 1, s = 1, ans = n;
    for (long long x = (n / 3) - 100; x <= (n / 3) + 100; x++)
      if (check(x)) s = x;
    int t, op = 1;
    query(s);
    cin >> t;
    while (l <= r) {
      long long mid = (l + r) >> 1;
      s += op * mid;
      op *= -1;
      assert(1 <= s && s <= n);
      query(s);
      cin >> t;
      if (t == 1)
        r = mid - 1, ans = mid;
      else
        l = mid + 1;
    }
    cout << "= " << ans << endl;
  }
  return 0;
}
