#include <iostream>
using namespace std;
class Solution {
public:
string getHappyString(int n, int k) {
string res(n, ' ');
int i = 0;
if(dfs(res, 0, i, n, k)) return res;
return "";
}
private:
bool dfs(string& s, int index, int& cnt, int n, int k){
if(index == n){
cnt ++;
return cnt == k;
}
for(char c: {'a', 'b', 'c'})
if(!index || c != s[index - 1]){
s[index] = c;
if(dfs(s, index + 1, cnt, n, k)) return true;
}
return false;
}
};
int main() {
cout << Solution().getHappyString(1, 3) << endl;
cout << Solution().getHappyString(1, 4) << endl;
cout << Solution().getHappyString(3, 9) << endl;
cout << Solution().getHappyString(2, 7) << endl;
cout << Solution().getHappyString(10, 100) << endl;
return 0;
}