#include <bits/stdc++.h>
template <typename T>
void read(T &x);
template <typename T>
void read(T &x, T &y);
template <typename T>
void read(T &x, T &y, T &z);
template <typename T>
void write(T x);
template <typename T>
void writeC(T x);
template <typename T>
void writeN(T x);
std::vector<int> query_list(std::vector<int> v) {
  char s1[100005], s2[100005];
  int N = v.size();
  printf("Q ");
  printf("%d ", (N) / 2);
  for (int i = 1; i <= (N) / 2; ++i)
    printf("%d %d ", v[i * 2 - 2], v[i * 2 - 1]);
  puts("");
  std::fflush(stdout);
  scanf("%s", s1 + 1);
  if (N > 2) {
    printf("Q ");
    printf("%d ", (N - 1) / 2);
    for (int i = 1; i <= (N - 1) / 2; ++i)
      printf("%d %d ", v[i * 2 - 1], v[i * 2]);
    puts("");
    std::fflush(stdout);
    scanf("%s", s2 + 1);
  }
  std::vector<int> result;
  for (int i = 2; i <= N; ++i) {
    if (i & 1)
      result.push_back(s2[i / 2] - '0');
    else
      result.push_back(s1[i / 2] - '0');
  }
  return result;
}
std::vector<int> shrink(int n) {
  std::vector<int> result;
  std::vector<int> v;
  for (int i = (1); i <= (n); ++i) v.push_back(i);
  std::vector<int> r = query_list(v);
  result.push_back(v[0]);
  for (int i = 0; i + 1 < v.size(); ++i)
    if (r[i] == 0) result.push_back(v[i + 1]);
  return result;
}
void solve() {
  int n;
  read(n);
  if (n == 1) {
    printf("A %d 0 0\n", n);
    for (int i = 1; i <= n; ++i) printf("%d ", i);
    printf("\n\n\n");
    std::fflush(stdout);
    return;
  }
  std::vector<int> G[4];
  std::vector<int> col;
  col.resize(n + 10);
  std::vector<int> v = shrink(n);
  std::vector<int> v1, v2;
  if (v.size() == 1) {
    printf("A %d 0 0\n", n);
    for (int i = 1; i <= n; ++i) printf("%d ", i);
    printf("\n\n\n");
    std::fflush(stdout);
    return;
  }
  int cnt = 0;
  for (int x : v) {
    if (cnt & 1)
      v1.push_back(x);
    else
      v2.push_back(x);
    cnt++;
  };
  std::vector<int> r1, r2;
  if (v1.size() > 1) r1 = query_list(v1);
  if (v2.size() > 1) r2 = query_list(v2);
  col[0] = 1;
  col[1] = 2;
  for (int i = 2; i < v.size(); ++i) {
    int pre_result;
    if (i & 1)
      pre_result = r1[i / 2 - 1];
    else
      pre_result = r2[i / 2 - 1];
    if (pre_result)
      col[i] = col[i - 2];
    else
      col[i] = 6 - col[i - 1] - col[i - 2];
  }
  v.push_back(n + 1);
  for (int i = 0; i + 1 < v.size(); ++i) {
    int x = v[i], y = v[i + 1];
    for (int j = x; j < y; ++j) G[col[i]].push_back(j);
  }
  printf("A %d %d %d\n", G[1].size(), G[2].size(), G[3].size());
  for (int x : G[1]) printf("%d ", x);
  puts("");
  for (int x : G[2]) printf("%d ", x);
  puts("");
  for (int x : G[3]) printf("%d ", x);
  puts("");
  std::fflush(stdout);
}
signed main() {
  int t;
  read(t);
  while (t-- > 0) solve();
}
template <typename T>
void read(T &x) {
  x = 0;
  char c = getchar();
  T flag = 1;
  while (c < '0' || c > '9') {
    if (c == '-') flag = -flag;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= flag;
}
template <typename T>
void read(T &x, T &y) {
  read(x);
  read(y);
}
template <typename T>
void read(T &x, T &y, T &z) {
  read(x);
  read(y);
  read(z);
}
template <typename T>
void writeC(T x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) writeC(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void write(T x) {
  writeC(x);
  putchar(' ');
}
template <typename T>
void writeN(T x) {
  writeC(x);
  puts("");
}
