```
def countAndSay(self, n):
from itertools import takewhile, islice
def generate_next(seq):
i, result = 0, []
while i < len(seq):
for j, d in enumerate(takewhile(lambda x: x == seq[i], seq[i:])):
continue
i += j + 1
result += [str(j+1), d]
return ''.join(result)
def generate():
cur = '1'
while True:
yield cur
cur = generate_next(cur)
return next(islice(generate(), n-1, None))
```