e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Competitions

Marathon weekend with restrictions

Product of digits

Given an integer n. Write a program to find the minimal positive integer k such that the product of its digits is exactly n.

Input

There are several tests. Each test consists of an integer n (0n109) on a single line.

Output

For each integer print in a single line the corresponding number k. If such k doesn't exist, print -1 instead.

Time limit 1 second
Memory limit 128 MiB
Input example #1
15
128
255
Output example #1
35
288
-1
Source Stage II All-Ukrainian Olympiad 2010-2011 Berdichev