#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b && (a = b, true);
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b && (a = b, true);
}
using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
ll N;
bool test(ll npos) {
  cout << "? " << npos << endl;
  int ans;
  cin >> ans;
  return ans == 1;
}
void solve() {
  cin >> N;
  ll lo = 0, hi = N;
  ll pos = 0;
  ll minPos = -1;
  bool right = true;
  while (lo + 1 < hi) {
    ll mi = (lo + hi) / 2;
    pos = right ? pos + mi : pos - mi;
    chmax(minPos, pos);
    right ^= 1;
    lo = mi;
  }
  pos = N - minPos;
  test(pos);
  lo = 0, hi = N;
  right = true;
  while (lo + 1 < hi) {
    ll mi = (lo + hi) / 2;
    ll npos = right ? pos + mi : pos - mi;
    pos = npos;
    right ^= 1;
    if (test(npos)) {
      hi = mi;
    } else {
      lo = mi;
    }
  }
  cout << "= " << hi << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
}
