def countAndSay(self, n: int) -> str:
if n == 1:
return '1'
out = ''
s = self.countAndSay(n-1)
count = 0
for i in range(len(s)):
c = s[i]
if i == 0 or c == s[i-1]:
count += 1
else:
out += str(count) + s[i-1]
count = 1
out += str(count) + c
return out