SP10450 AMOEBA - Amoeba

Description

Dr. Fulano found a new species of microorganism, the fast-growing-amoeba. The colony of this kind of amoeba grows vary fast. To find out the exacty rate of growth of the colony, Dr. Fulano wrote down for several days, the number of amoebae in the colony. Soon he realized that each individual generate daily, 6 new individuals. As the number of amoebae grew very quickly, Dr. Fulano noted only the last K digits. When he realized that the numbers noted were repeated, it was too late! The research was already well advanced and there was no time to recount. The solution was to ask for help from you. Doctor Fulano will give to you a number of K digits (0 < K < 10), possibly with leading zeroes. You should answer the first day he wrote down that number. Consider that in day 1, the colony was composed of 1 amoeba. Consider also that an amoeba does not disappear when generating his descendants. If there is no answer to the number given, print -1.

Input Format

The input is composed by various numbers, each in one line.

Output Format

For each line in input, print a line in output. The line should contains the required answer without leading zeroes.