#include <bits/stdc++.h>
using namespace std;
int tc;
long long n;
long long get_first(long long x) {
  long long rl = 1;
  long long rr = x - 1;
  long long mult = 1;
  vector<long long> li;
  while (rl <= rr) {
    long long mid = (rl + rr) / 2;
    mult *= -1;
    li.push_back(mult * mid);
    rl = mid + 1;
  }
  long long ret = x;
  if (li.back() > 0) ret = 1;
  for (auto y : li) {
    ret += y;
  }
  return ret;
}
bool tanya(long long x) {
  printf("? %lld\n", x);
  fflush(stdout);
  int ret;
  scanf("%d", &ret);
  return ret;
}
void jawab(long long x) {
  printf("= %lld\n", x);
  fflush(stdout);
  return;
}
long long solve(long long cl, long long cr, long long bef) {
  long long ret = cr + 1;
  long long mult = -1;
  while (cl <= cr) {
    long long mid = (cl + cr) / 2;
    mult *= -1;
    mid *= mult;
    bef += mid;
    if (tanya(bef)) {
      ret = abs(mid);
      cr = abs(mid) - 1;
    } else {
      cl = abs(mid) + 1;
    }
  }
  return ret;
}
int main() {
  scanf("%d", &tc);
  while (tc--) {
    scanf("%lld", &n);
    long long awal = get_first(n);
    tanya(awal);
    long long ans = solve(1, n - 1, awal);
    jawab(ans);
  }
  return 0;
}
