#include <bits/stdc++.h>
using namespace std;
ifstream fin("lampa.in");
ofstream fout("lampa.out");
int N, M;
string A, B, C, S;
void valid(const char a[], const char b[])
{
int p = 0, n = strlen(a), m = strlen(b);
for(unsigned int i = 0; i < C.size(); ++i)
{
if(C[i] == 'A')
{
if(memcmp(S.c_str()+p, a, n)) return;
p += n;
}
else
{
if(memcmp(S.c_str()+p, b, m)) return;
p += m;
}
}
fout << a << '\n';
fout << b << '\n';
exit(0);
}
int main()
{
fin >> N >> M >> S;
A = "A", B = "B";
int Acf = 0, Bcf = 1, Scf = 1;
for(int i = 3, poz = i&1; i <= N; ++i, poz = 1-poz)
{
Acf = Bcf, Bcf = Scf, Scf = Acf + Bcf;
C = A+B, A = B, B = C;
}
for(int asize = 1; asize*Acf <= M; ++asize)
{
if((M-asize*Acf) % Bcf == 0)
{
int bsize = (M-asize*Acf) / Bcf;
A = N&1 ? S.substr(0, asize) : S.substr(bsize, asize);
B = N&1 ? S.substr(asize, bsize) : S.substr(0, bsize);
valid(A.c_str(), B.c_str());
}
}
fout << 0 << '\n';
return 0;
}