class Solution:
def countAndSay(self, n: int) -> str:
result = '1'
while n > 1:
s = result
result = ''
i = 0
while i < len(s):
value = s[i]
count = 0
while i < len(s) and s[i] == value:
count += 1
i += 1
result += str(count) + str(value)
n -= 1
return result