Na2a and lucky stone

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
A number is called as a lucky number if its decimal representation contains only the lucky digits, 4 and 7. e.g. 47, 744, 4 are lucky numbers, whereas 5, 17, 467 are not.
Recently, Na2a found a magic stone. With the help of this stone, he can multiply a number by any lucky number. Also, the magic stone can be used any number of times (possibly zero or infinite number of times).
For example, if initially he has the number 1, then he can get numbers like 28 (formed by 1*4*7), 14476 (formed as 1*47*77*4) etc.
Na2a has N numbers in his bag which are denoted by array A. For each number A_{i} in his bag, he asks you to transform it to a number with maximum possible number of trailing zeroes by using Magic Stone. You have to find the smallest of such numbers, since there can be multiple numbers with the maximum possible number of trailing zeros.
Input
 There is a single test case.
 First line contains a single integer N as stated in the problem.
 The second line contains N spaceseparated integers A_{1}, A_{2}, ... , A_{N} where A_{i} denotes the i^{th} number in the bag.
Output
 Output N lines, in which i^{th} line contains the answer corresponding to the number A_{i}.
Constraints
 1 ≤ N ≤ 10^{5}
 1 ≤ A_{i} ≤ 10^{9}
Subtasks
Subtask 1(8 points)
 1 ≤ N ≤ 10
 1 ≤ A_{i} ≤ 10
Subtask 2(22 points)
 1 ≤ N ≤ 10^{2}
 1 ≤ A_{i} ≤ 10^{3}
Subtask 3(70 points)
 Original constraints
Example
Input: 2 2 15 Output: 2 60
Explanation
Example case 1. You can't get any number having zeros at the end multiplying 2 by lucky numbers.
Example case 2. You can multiply 15 by 4 and get 60, which has one trailing zero.
Author:  na2a 
Tester:  mugurelionut 
Editorial  http://discuss.codechef.com/problems/LCKYST 
Tags  july15, maths, na2a, simple 
Date Added:  8042015 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 