#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return (size_t)splitmix64(x + FIXED_RANDOM);
  }
  size_t operator()(pair<uint64_t, uint64_t> x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return (size_t)(splitmix64(x.first + FIXED_RANDOM) ^
                    (splitmix64(x.second + FIXED_RANDOM) >> 1));
  }
};
ll n, m, k, t, a;
list<ll> q;
unordered_map<ll, bool, custom_hash> visited;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> t;
  while (t--) {
    cin >> n;
    ll l = 1;
    ll r = n;
    q.clear();
    visited.clear();
    while (l < r) {
      ll c = l + (r - l) / 2;
      q.push_front(c);
      l = c + 1;
    }
    k = n;
    for (ll j : q) {
      if (k > j) {
        k -= j;
      } else {
        k += j;
      }
    }
    l = 1;
    r = n;
    cout << "? " << k << endl;
    visited[k] = 1;
    cin >> a;
    while (l < r) {
      ll c = l + (r - l) / 2;
      bool aa = false;
      while (!aa) {
        aa = true;
        if (k + c <= n && visited[k + c] != true) {
          visited[k + c] = 1;
          cout << "? " << k + c << endl;
          cin >> a;
          if (a == 1) {
            r = min(r, c);
          } else {
            l = max(l, c + 1);
          }
          k += c;
        } else if (k - c >= 1 && visited[k - c] != true) {
          visited[k - c] = 1;
          cout << "? " << k - c << endl;
          cin >> a;
          if (a == 1) {
            r = min(r, c);
          } else {
            l = max(l, c + 1);
          }
          k -= c;
        } else {
          aa = false;
          c--;
        }
      }
    }
    cout << "= " << l << endl;
  }
  return 0;
}
