Find the password

4

1 votes
Problem

Dom and Brian have come across this locker which they can't open. The fate of the mission depends on it. They have to open it at any cost. Tej has found the pattern in the combination. The pattern goes like this, given a number X between 0 to 10^9+6 find smallest positive integer Y such that the products of digits of Y modulo 10^9+7 is X. This Y is the combination of the lock. Help Dom and Brian open this safe.

Input: A single integer, X.

Output: A single integer, Y.

Input: 0 <= X <= 10^9+6

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

If X is 16 then Y is 28 as (2*8)%1000000007 = 16

Editor Image

?