k = int(eval(input()))



nums = [i for i in range(1,10)]

for i in range(k):

  a = nums.pop(0)

  

  if a%10 != 0:

    nums.append(a*10 + a%10 - 1)

    

  nums.append(a*10 + a%10)

  

  if a%10 != 9:

    nums.append(a*10 + a%10 + 1)

print(a)
from collections import deque

k = int(eval(input()))



q = deque([i for i in range(1,10)])

for i in range(k):

  a = q.popleft()

  

  if a%10 != 0:

    q.append(a*10 + a%10 - 1)

    

  q.append(a*10 + a%10)

  

  if a%10 != 9:

    q.append(a*10 + a%10 + 1)

print(a)
k = int(eval(input()))
nums = [i for i in range(1, 10)]
for i in range(k):
    a = nums.pop(0)
    if a % 10 != 0:
        nums.append(a * 10 + a % 10 - 1)
    nums.append(a * 10 + a % 10)
    if a % 10 != 9:
        nums.append(a * 10 + a % 10 + 1)
print(a)

from collections import deque

k = int(eval(input()))
q = deque([i for i in range(1, 10)])
for i in range(k):
    a = q.popleft()
    if a % 10 != 0:
        q.append(a * 10 + a % 10 - 1)
    q.append(a * 10 + a % 10)
    if a % 10 != 9:
        q.append(a * 10 + a % 10 + 1)
print(a)

+from collections import deque + -nums = [i for i in range(1, 10)] +q = deque([i for i in range(1, 10)]) -    a = nums.pop(0) +    a = q.popleft() -        nums.append(a * 10 + a % 10 - 1) -    nums.append(a * 10 + a % 10) +        q.append(a * 10 + a % 10 - 1) +    q.append(a * 10 + a % 10) -        nums.append(a * 10 + a % 10 + 1) +        q.append(a * 10 + a % 10 + 1)