#include <bits/stdc++.h>
using namespace std;
vector<int> v, f(1e6, 0);
int main() {
  int N, x;
  cin >> N >> x;
  v.resize(x, 0);
  for (int i = 0; i < N; i++) {
    cout << "A" << endl;
    int a;
    cin >> a;
    for (int j = 0; j < v.size(); j++)
      if (a % x == j) v[j]++;
    cout << "B" << endl;
    for (int j = 0; j < v.size(); j++) cout << v[j] << " ";
    cout << endl;
    for (int j = 0; j < v.size(); j++)
      for (int k = 0; k < v[j]; k++) f[j + k * x] = 1;
    cout << "C" << endl;
    for (int j = 0; j < f.size(); j++)
      if (f[j] == 0) {
        cout << j << endl;
        break;
      }
    cout << "D" << endl;
    f.resize(1e5, 0);
  }
}
