#include <bits/stdc++.h>
using namespace std;
const int INF = 1e18 + 1;
const int N = 1e6 + 1;
template <class T>
bool tmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool tmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
long long t, n, a;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    if (n == 1) {
      cout << "= 1\n";
      continue;
    }
    long long l = 1, r = n - 1, g = 1, mx = 0, h;
    bool tf = 1;
    while (l <= r) {
      long long mid = (r + l) / 2;
      g += (tf ? mid : -mid);
      l = mid + 1;
      if (g <= 0) mx = max(mx, 1 - g);
      tf = 1 - tf;
    }
    tf = 1;
    l = 1;
    g = mx + 1;
    cout << "? " << g << "\n";
    cin >> h;
    while (l <= r) {
      long long mid = (r + l) / 2;
      g += (tf ? mid : -mid);
      cout << "? " << g << "\n";
      cin >> h;
      if (h)
        r = mid - 1;
      else
        l = mid + 1;
      tf = 1 - tf;
    }
    cout << "= " << max(l, r) << "\n";
  }
}
