K = int(eval(input()))

A = [1,2,3,4,5,6,7,8,9]

for i in range(len(A)):

    if A[i] != 9:

        for j in range(-1,2):

            a = int(str(A[i]) + str(A[i]+j))

            A.append(a)

    else:

        A.append(98)

        A.append(99)

A.append(100)

A.append(101)

L1 = len(A.copy())

for i in range(10, L1):

    B = A[i]

    if B % 10 == 0:

        A.append(int(str(B) + '0'))

        A.append(int(str(B) + '1'))

    elif B % 10 == 9:

        A.append(int(str(B) + '8'))

        A.append(int(str(B) + '9'))

    else:

        for j in range(-1, 2):

            a = int(str(B) + str((B % 10) + j))

            A.append(a)

L2 = len(A.copy())

for i in range(8):

    for i in range(L1,L2):

        B = A[i]

        if B % 10 == 0:

            A.append(int(str(B) + '0'))

            A.append(int(str(B) + '1'))

        elif B % 10 == 9:

            A.append(int(str(B) + '8'))

            A.append(int(str(B) + '9'))

        else:

            for j in range(-1, 2):

                a = int(str(B) + str((B % 10) + j))

                A.append(a)

    L1 = L2

    L2 = len(A.copy())

print((A[K-1]))
K = int(eval(input()))

A = [1,2,3,4,5,6,7,8,9]

for i in range(len(A)):

    if A[i] != 9:

        for j in range(-1,2):

            a = int(str(A[i]) + str(A[i]+j))

            A.append(a)

    else:

        A.append(98)

        A.append(99)

A.append(100)

A.append(101)

L1 = 10

L2 = len(A.copy())

for i in range(8):

    for i in range(L1,L2):

        B = A[i]

        if B % 10 == 0:

            A.append(int(str(B) + '0'))

            A.append(int(str(B) + '1'))

        elif B % 10 == 9:

            A.append(int(str(B) + '8'))

            A.append(int(str(B) + '9'))

        else:

            for j in range(-1, 2):

                a = int(str(B) + str((B % 10) + j))

                A.append(a)

    L1 = L2

    L2 = len(A.copy())

print((A[K-1]))
K = int(eval(input()))
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(len(A)):
    if A[i] != 9:
        for j in range(-1, 2):
            a = int(str(A[i]) + str(A[i] + j))
            A.append(a)
    else:
        A.append(98)
        A.append(99)
A.append(100)
A.append(101)
L1 = len(A.copy())
for i in range(10, L1):
    B = A[i]
    if B % 10 == 0:
        A.append(int(str(B) + "0"))
        A.append(int(str(B) + "1"))
    elif B % 10 == 9:
        A.append(int(str(B) + "8"))
        A.append(int(str(B) + "9"))
    else:
        for j in range(-1, 2):
            a = int(str(B) + str((B % 10) + j))
            A.append(a)
L2 = len(A.copy())
for i in range(8):
    for i in range(L1, L2):
        B = A[i]
        if B % 10 == 0:
            A.append(int(str(B) + "0"))
            A.append(int(str(B) + "1"))
        elif B % 10 == 9:
            A.append(int(str(B) + "8"))
            A.append(int(str(B) + "9"))
        else:
            for j in range(-1, 2):
                a = int(str(B) + str((B % 10) + j))
                A.append(a)
    L1 = L2
    L2 = len(A.copy())
print((A[K - 1]))

K = int(eval(input()))
A = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(len(A)):
    if A[i] != 9:
        for j in range(-1, 2):
            a = int(str(A[i]) + str(A[i] + j))
            A.append(a)
    else:
        A.append(98)
        A.append(99)
A.append(100)
A.append(101)
L1 = 10
L2 = len(A.copy())
for i in range(8):
    for i in range(L1, L2):
        B = A[i]
        if B % 10 == 0:
            A.append(int(str(B) + "0"))
            A.append(int(str(B) + "1"))
        elif B % 10 == 9:
            A.append(int(str(B) + "8"))
            A.append(int(str(B) + "9"))
        else:
            for j in range(-1, 2):
                a = int(str(B) + str((B % 10) + j))
                A.append(a)
    L1 = L2
    L2 = len(A.copy())
print((A[K - 1]))

-L1 = len(A.copy()) -for i in range(10, L1): -    B = A[i] -    if B % 10 == 0: -        A.append(int(str(B) + "0")) -        A.append(int(str(B) + "1")) -    elif B % 10 == 9: -        A.append(int(str(B) + "8")) -        A.append(int(str(B) + "9")) -    else: -        for j in range(-1, 2): -            a = int(str(B) + str((B % 10) + j)) -            A.append(a) +L1 = 10