K = int(input())



N = [0]



for _ in range(K):

    i = 0

    while i < len(N) and N[i] == 9:

        i += 1

    while i+1 < len(N) and N[i] == N[i+1]+1:

        i += 1

    if i == len(N):

        N = [0]*len(N) + [1]

    else:

        N[i] += 1

        i -= 1

        while i >= 0:

            N[i] = max(N[i+1]-1,0)

            i -= 1



print(*reversed(N),sep='')

from collections import deque



K = int(eval(input()))



q = deque(list(range(1,10)))



for _ in range(K):

    x = q.popleft()

    r = x%10

    if r == 0:

        q.append(x*10)

        q.append(x*10+1)

    elif r == 9:

        q.append(x*10+8)

        q.append(x*10+9)



    else:

        q.append(x*10+r-1)

        q.append(x*10+r)

        q.append(x*10+r+1)

print(x)
K = int(input())
N = [0]
for _ in range(K):
    i = 0
    while i < len(N) and N[i] == 9:
        i += 1
    while i + 1 < len(N) and N[i] == N[i + 1] + 1:
        i += 1
    if i == len(N):
        N = [0] * len(N) + [1]
    else:
        N[i] += 1
        i -= 1
        while i >= 0:
            N[i] = max(N[i + 1] - 1, 0)
            i -= 1
print(*reversed(N), sep="")

from collections import deque

K = int(eval(input()))
q = deque(list(range(1, 10)))
for _ in range(K):
    x = q.popleft()
    r = x % 10
    if r == 0:
        q.append(x * 10)
        q.append(x * 10 + 1)
    elif r == 9:
        q.append(x * 10 + 8)
        q.append(x * 10 + 9)
    else:
        q.append(x * 10 + r - 1)
        q.append(x * 10 + r)
        q.append(x * 10 + r + 1)
print(x)

-K = int(input()) -N = [0] +from collections import deque + +K = int(eval(input())) +q = deque(list(range(1, 10))) -    i = 0 -    while i < len(N) and N[i] == 9: -        i += 1 -    while i + 1 < len(N) and N[i] == N[i + 1] + 1: -        i += 1 -    if i == len(N): -        N = [0] * len(N) + [1] +    x = q.popleft() +    r = x % 10 +    if r == 0: +        q.append(x * 10) +        q.append(x * 10 + 1) +    elif r == 9: +        q.append(x * 10 + 8) +        q.append(x * 10 + 9) -        N[i] += 1 -        i -= 1 -        while i >= 0: -            N[i] = max(N[i + 1] - 1, 0) -            i -= 1 -print(*reversed(N), sep="") +        q.append(x * 10 + r - 1) +        q.append(x * 10 + r) +        q.append(x * 10 + r + 1) +print(x)