#include <bits/stdc++.h>
int query(long long i) {
  int x;
  printf("? %lld\n", i), fflush(stdout);
  scanf("%d", &x);
  return x;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    long long n, m, l, r, c;
    int turn;
    scanf("%lld", &n);
    l = 0;
    for (m = n - 1; m > 0; m /= 4) l -= (m + 1) / 2;
    l = 1 - l, r = l, m = n - 1, turn = 0;
    query(r);
    c = 1;
    for (m = n - 1; m > 0; m /= 2, turn ^= 1)
      if (turn == 0) {
        if (query(l -= (m + 1) / 2))
          r -= (m + 1) / 2, m--;
        else
          c += (m + 1) / 2;
      } else {
        if (query(r += (m + 1) / 2))
          l += (m + 1) / 2, m--;
        else
          c += (m + 1) / 2;
      }
    printf("= %lld\n", c), fflush(stdout);
  }
  return 0;
}
