from itertools import permutations n = int(input()) for c in permutations(range(10)): if n == 1: if c[0] == 0 or c[3] == 0 or c[1] == 0: continue if (100 * c[0] + 10 * c[1] + c[2] + 100 * c[3] + 10 * c[4] + c[5] == 1001 * c[1] + 100 * c[6] + 10 * c[2]): print(1001 * c[1] + 100 * c[6] + 10 * c[2]) break elif n == 2: if c[0] == 0 or c[3] == 0 or c[7] == 0: continue if (1100 * c[0] + 10 * c[1] + c[2] + 1000 * c[3] + 100 * c[4] + 10 * c[5] + c[6] == 10000 * c[7] + 1000 * c[8] + 100 * c[1] + 10 * c[2] + c[9]): print(10000 * c[7] + 1000 * c[8] + 100 * c[1] + 10 * c[2] + c[9]) break else: if c[0] == 0 or c[6] == 0 or c[1] == 0: continue if (100000 * c[0] + 10000 * c[1] + 1000 * c[2] + 100 * c[3] + 10 * c[4] + c[5] + 10000 * c[6] + 1000 * c[3] + 100 * c[5] + 10 * c[7] + c[8] == 100000 * c[1] + 10010 * c[3] + 1001 * c[9] + 100 * c[4]): print(100000 * c[1] + 10010 * c[3] + 1001 * c[9] + 100 * c[4]) break