static int x=[](){
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return 0;
}();
class Solution {
public:
string countAndSay(int n) {
if (n == 1) {
return "1";
} else {
string output = countAndSay(n - 1), result = "";
int index = 0;
while (index < output.length()) {
char current = output[index];
int cursor = index, count = 0;
while (cursor < output.length() && output[cursor] == current) {
cursor++;
count++;
}
char number = count + '0';
result += number;
result += current;
index += count;
}
return result;
}
}
};