#include <bits/stdc++.h>
using namespace std;
template <class D>
inline void read(D &res) {
  res = 0;
  register D g = 1;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') g = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    res = (res << 3) + (res << 1) + (ch ^ 48);
    ch = getchar();
  }
  res *= g;
}
int T;
long long n, m, sn, l, r, f, s, w;
inline long long calc(long long x) {
  if (x == n) return sn = 1, 1;
  long long mid = (n + x - 1) >> 1, res = calc(mid + 1) + sn * mid;
  return sn = -sn, res;
}
inline void getit(long long d = abs(s - f)) {
  fflush(stdout);
  cin >> w;
  if (w)
    r = d;
  else
    l = d + 1ll;
}
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    l = 1ll;
    r = n;
    f = calc(1);
    s = f + sn * ((l + r - 1) >> 1);
    sn = -sn;
    cout << "? " << f << endl;
    fflush(stdout);
    cin >> w;
    cout << "? " << s << endl;
    getit();
    while (l < r) {
      f = s;
      s = f + sn * ((l + r - 1) >> 1);
      sn = -sn;
      cout << "? " << s << endl;
      getit();
    }
    cout << "= " << l << endl;
    fflush(stdout);
  }
  return 0;
}
