5.89%

Max. Score:100

Given a number **N**. Find a number **K** such that product of digits of **K** must be equal to **N**.

**Note :** **K** must be as smallest as possible.

**Input:** First line of input contains number of testcases T. For each testcase, there will be a single line containing N.

**Output:** For each testcase, output single integer. If K is not possible, print "**-1**" (without quotes).

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{15}

**Example:
Input:**

2

12

5

**Output:**

26

5

**Explanation:**

**Testcase 1: **26 is the smallest number, and product of 2 and 6 is 12.

**Testcase 2: **5 is the smallest number which is itself equal to 5.

Login to report an issue on this page.