#include <bits/stdc++.h>
using namespace std;
int T, a;
long long n, ans, l, r, mid, pos, op;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%lld", &n);
    if (n == 2) {
      printf("? 1\n");
      fflush(stdout);
      scanf("%d", &a);
      printf("? 2\n");
      fflush(stdout);
      scanf("%d", &a);
      if (a)
        printf("= 1\n");
      else
        printf("= 2\n");
      fflush(stdout);
      continue;
    } else {
      l = 1, r = n - 1, pos = 0, op = 1;
      while (l <= r) {
        mid = (l + r) / 2;
        pos += op * mid, l = mid + 1, op *= -1;
      }
      if (pos < 0)
        pos = 1 - pos;
      else
        pos = n - pos;
    }
    ans = n;
    l = 1, r = n - 1;
    printf("? %lld\n", pos);
    fflush(stdout);
    scanf("%d", &a), op = 1;
    while (l <= r) {
      mid = (l + r) / 2;
      pos += op * mid;
      printf("? %lld\n", pos);
      fflush(stdout);
      scanf("%d", &a);
      if (a)
        ans = mid, r = mid - 1;
      else
        l = mid + 1;
      op *= -1;
    }
    printf("= %lld\n", ans);
    fflush(stdout);
  }
  return 0;
}
