#include using namespace std; const int MX = 10000000; int tmp[4 * MX]; int main() { int T; scanf("%d", &T); while (T--) { int n; scanf("%d", &n); int* lc = tmp; int* rc = tmp + MX; int* lp = tmp + MX * 2; int* rp = tmp + MX * 3; int ccnt = 1, pcnt = 0; lc[0] = 1; rc[0] = n; for (int i = n - 1; i > 0; i--) { swap(ccnt, pcnt); swap(lc, lp); swap(rc, rp); ccnt = 0; int j = 0, k = 0, p = 0, q = 0, bal = 0, last = 1; while (q < pcnt && last <= n) { int x = n + 1; if (j < pcnt) x = min(x, lp[j] - i); if (k < pcnt) x = min(x, rp[k] - i + 1); if (p < pcnt) x = min(x, lp[p] + i); if (q < pcnt) x = min(x, rp[q] + i + 1); if (bal == 0 && x > last) { lc[ccnt] = last; rc[ccnt] = x - 1; ccnt++; } if (j < pcnt && lp[j] - i == x) bal++, j++; if (k < pcnt && rp[k] - i + 1 == x) bal--, k++; if (p < pcnt && lp[p] + i == x) bal++, p++; if (q < pcnt && rp[q] + i + 1 == x) bal--, q++; last = max(x, 1); } if (last <= n) { lc[ccnt] = last; rc[ccnt] = n; ccnt++; } } static int ans[MX + 1]; for (int i = 1; i <= n; i++) ans[i] = 1; for (int i = 0; i < ccnt; i++) for (int j = lc[i]; j <= rc[i]; j++) ans[j] = 2; int m; scanf("%d", &m); while (m--) { int x; scanf("%d", &x); printf("%d ", ans[x]); } printf("\n"); } return 0; }