#include <iostream>
using namespace std;
int n, d = 1;
char a[10];
void pr() {
cout<< d<< ": ";
for (int i = 0; i < n; i++)
cout << a[i] << " ";
cout << endl;
d++;
}
void permutation(int i) {
for (char c : {'A', 'B'}) {
if (i == 0 || a[i - 1] != 'B' || c != 'B') { // Kiểm tra không có 2 chữ B cạnh nhau
a[i] = c;
if (i == n - 1)
pr();
else
permutation(i + 1);
}
}
}
int main() {
cin >> n;
permutation(0);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG4sIGQgPSAxOwpjaGFyIGFbMTBdOwoKdm9pZCBwcigpIHsKICAgIGNvdXQ8PCBkPDwgIjogIjsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgICAgIGNvdXQgPDwgYVtpXSA8PCAiICI7CiAgICBjb3V0IDw8IGVuZGw7CiAgICBkKys7Cn0KCnZvaWQgcGVybXV0YXRpb24oaW50IGkpIHsKICAgIGZvciAoY2hhciBjIDogeydBJywgJ0InfSkgewogICAgICAgIGlmIChpID09IDAgfHwgYVtpIC0gMV0gIT0gJ0InIHx8IGMgIT0gJ0InKSB7IC8vIEtp4buDbSB0cmEga2jDtG5nIGPDsyAyIGNo4buvIEIgY+G6oW5oIG5oYXUKICAgICAgICAgICAgYVtpXSA9IGM7CiAgICAgICAgICAgIGlmIChpID09IG4gLSAxKQogICAgICAgICAgICAgICAgcHIoKTsKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgcGVybXV0YXRpb24oaSArIDEpOwogICAgICAgIH0KICAgIH0KfQoKaW50IG1haW4oKSB7CiAgICBjaW4gPj4gbjsKICAgIHBlcm11dGF0aW9uKDApOwp9Cg==