def solve(n, k): string = "" while n > 0: letter = min(26, k-n+1) string += chr(letter + ord('a') - 1) k -= letter n -= 1 return string[::-1] n = 4 k = 16 print(solve(n, k))