atcoder#ARC153A. [ARC153A] AABCDDEFE

[ARC153A] AABCDDEFE

Score : 300300 points

Problem Statement

A positive integer xx is said to be a beautiful integer if and only if xx is a 99-digit integer whose decimal notation S1S9S_1\ldots S_9 (SiS_i is the ii-th character) satisfies all of the following conditions:

  • S1S_1 is not 0,
  • S1=S2S_1 = S_2,
  • S5=S6S_5 = S_6, and
  • S7=S9S_7 = S_9.

For instance, 998244353998244353 and 333333333333333333 are beautiful integers, while 111112222111112222 is not, since S5S6S_5 \neq S_6.

You are given a positive integer NN. Print the NN-th smallest beautiful integer.

Constraints

  • NN is a positive integer.
  • There are at least NN beautiful integers.

Input

The input is given from Standard Input in the following format:

NN

Output

Print the NN-th smallest beautiful integer.

3
110000020

The beautiful integers in ascending order are 110000000,110000010,110000020,110000000, 110000010, 110000020, \ldots.

882436
998244353
2023
110200222