#include <bits/stdc++.h>
void plot(const std::vector<int> &v) {
  printf(":: ");
  for (int x : v) printf("%d ", x);
  puts("");
}
std::vector<int> query(const std::vector<int> &a) {
  if (a.size() <= 1) return std::vector<int>();
  std::vector<int> ret(a.size() - 1);
  for (int start = 0; start < 2; ++start) {
    int sz = (a.size() - start) / 2;
    if (sz > 0) {
      std::cout << "Q " << ((a.size() - start) / 2);
      for (int i = start; i + 1 < a.size(); i += 2) {
        std::cout << " " << (a[i] + 1) << " " << (a[i + 1] + 1);
      }
      std::cout << std::endl;
      std::cout.flush();
      std::string s;
      std::cin >> s;
      for (int i = 0; i < s.length(); ++i) ret[start + i * 2] = s[i] == '1';
    }
  }
  return ret;
}
int main() {
  int cas;
  std::cin >> cas;
  while (cas--) {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    std::iota(a.begin(), a.end(), 0);
    std::vector<int> q1 = query(a);
    std::vector<int> groups;
    for (int i = 0, j = 0; i < n; i = ++j) {
      while (j + 1 < n && q1[j] == 1) ++j;
      groups.emplace_back(i);
    }
    std::vector<int> grouped_color(groups.size());
    if (groups.size() > 1) {
      std::vector<int> q2(groups.size() - 1);
      for (int start = 0; start < 2; ++start) {
        std::vector<int> b, q;
        for (int i = start; i < groups.size(); i += 2)
          b.emplace_back(groups[i]);
        q = query(b);
        for (int i = 0; i + 1 < b.size(); ++i) q2[start + 2 * i] = q[i];
      }
      grouped_color[1] = 1;
      for (int i = 0; i + 2 < grouped_color.size(); ++i) {
        if (q2[i] == 1)
          grouped_color[i + 2] = grouped_color[i];
        else
          grouped_color[i + 2] = 3 ^ grouped_color[i] ^ grouped_color[i + 1];
      }
    }
    std::vector<int> result[3];
    for (int i = 0, j = 0, at = 0; i < n; i = ++j, ++at) {
      while (j + 1 < n && q1[j] == 1) ++j;
      for (int k = i; k <= j; ++k) result[grouped_color[at]].emplace_back(k);
    }
    std::cout << "A " << result[0].size() << " " << result[1].size() << " "
              << result[2].size() << std::endl;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < result[i].size(); ++j) {
        if (j != 0) std::cout << " ";
        std::cout << (result[i][j] + 1);
      }
      std::cout << std::endl;
      std::cout.flush();
    }
  }
}
