#include <bits/stdc++.h>
using namespace std;
int t, n, m, i, j, f, e, o;
vector<int> V, V2, O, E, B;
int C[100001], color[100001], F[10];
vector<int> ask(vector<int> V) {
  int sz = V.size();
  vector<int> B;
  if (sz <= 1) return B;
  B.resize(sz - 1);
  char str[100001];
  printf("Q %d", sz / 2);
  for (i = 0; i + 1 < sz; i += 2) printf(" %d %d", V[i], V[i + 1]);
  printf("\n");
  cout.flush();
  scanf("%s", str);
  for (i = 0; i + 1 < sz; i += 2) B[i] = str[i / 2] - '0';
  if ((sz - 1) / 2) {
    printf("Q %d", (sz - 1) / 2);
    for (i = 1; i + 1 < sz; i += 2) printf(" %d %d", V[i], V[i + 1]);
    printf("\n");
    cout.flush();
    scanf("%s", str);
    for (i = 1; i + 1 < sz; i += 2) B[i] = str[i / 2] - '0';
  }
  return B;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    if (n == -1) return 0;
    V.clear();
    for (i = 1; i <= n; i++) V.push_back(i);
    B = ask(V);
    V.clear();
    V.push_back(1);
    for (i = 0; i + 1 < n; i++)
      if (B[i] == 0) V.push_back(i + 2);
    m = V.size();
    V2.clear();
    for (i = 1; i < m; i += 2) V2.push_back(V[i]);
    O = ask(V2);
    V2.clear();
    for (i = 0; i < m; i += 2) V2.push_back(V[i]);
    E = ask(V2);
    e = E.size();
    o = O.size();
    E.resize(n);
    O.resize(n);
    for (i = e - 1; i >= 0; i--) E[2 * i] = E[i];
    for (i = o - 1; i >= 0; i--) O[2 * i + 1] = O[i];
    C[0] = 1;
    C[1] = 2;
    for (i = 2; i < m; i++)
      if (i % 2 == 0)
        if (E[i - 2] == 1)
          C[i] = C[i - 2];
        else
          for (C[i] = 1; C[i] == C[i - 2] || C[i] == C[i - 1]; C[i]++)
            ;
      else if (O[i - 2] == 1)
        C[i] = C[i - 2];
      else
        for (C[i] = 1; C[i] == C[i - 2] || C[i] == C[i - 1]; C[i]++)
          ;
    color[1] = C[0];
    j = 1;
    for (i = 0; i + 1 < n; i++)
      if (B[i] == 0)
        color[i + 2] = C[j++];
      else
        color[i + 2] = color[i + 1];
    F[1] = F[2] = F[3] = 0;
    for (i = 1; i <= n; i++) F[color[i]]++;
    printf("A %d %d %d\n", F[1], F[2], F[3]);
    for (i = 1; i <= 3; i++) {
      f = 0;
      for (j = 1; j <= n; j++)
        if (color[j] == i) {
          if (f) printf(" ");
          f = 1;
          printf("%d", j);
        }
      printf("\n");
    }
    cout.flush();
  }
  return 0;
}
