#include <iostream>
using namespace std;
void Gen(string haslo,int size,const string alfabet)
{
if (haslo.length()>=size) cout<<haslo<<endl;
else for(int i=0;i<alfabet.length();++i) Gen(haslo+alfabet[i],size,alfabet);
}
int main()
{
string alfabet="ab";
Gen("",2,alfabet);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPiAgCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIEdlbihzdHJpbmcgaGFzbG8saW50IHNpemUsY29uc3Qgc3RyaW5nIGFsZmFiZXQpCiAgewogICBpZiAoaGFzbG8ubGVuZ3RoKCk+PXNpemUpIGNvdXQ8PGhhc2xvPDxlbmRsOwogICBlbHNlIGZvcihpbnQgaT0wO2k8YWxmYWJldC5sZW5ndGgoKTsrK2kpIEdlbihoYXNsbythbGZhYmV0W2ldLHNpemUsYWxmYWJldCk7CiAgfQogIAppbnQgbWFpbigpCiAgewogICBzdHJpbmcgYWxmYWJldD0iYWIiOwogICBHZW4oIiIsMixhbGZhYmV0KTsKICAgcmV0dXJuIDA7CiAgfQoK