---
languages_supported:
- NA
title: DIGITS
category: NA
old_version: true
problem_code: DIGITS
tags:
- NA
layout: problem
---
### All submissions for this problem are available.
The chef may be losing his mind. He has demanded you solve the following task: given an integer P, find the smallest positive integer whose product of digits, modulo 1000000007, is P. You can't imagine what this has to do with cooking, but you'd better do what he says or you won't get to sample his culinary delights.
### Input:
Input will begin with a positive integer T<=15, the number of test cases. T lines follow, each containing an integer P between 0 and 1000000006, inclusive.
### Output:
For each test case, print on a single line the smallest positive integer whose product of digits, modulo 1000000007, is P. It is guaranteed that such an integer exists with fewer than 700 digits.
### Sample input:
<pre>4
16
486
220703118
0
</pre>### Sample output:
<pre>28
699
5555555555555
10
</pre>