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 space-separated 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$

----- Sample Input 1 ------ 
2

2 15
----- Sample Output 1 ------ 
2

60
----- explanation 1 ------ 
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.

Source: codechef | Difficulty: MEDIUM
Tags: Mathematics


Solutions:
def trailZero(x):
	x = str(x)
	count = 0
	for y in range(len(x) - 1, -1, -1):
		if x[y] != '0':
			return count
		count += 1
cases = int(input().strip())
nos = input().strip().split()
data = [4, 7]
curr = ['7', '4']
next = []
for x in range(9):
	for y in curr:
		next += [y + '4']
		next += [y + '7']
	data += [int(y) for y in next]
	curr = next
	next = []
data.sort()
for x in nos:
	y = int(x)
	while trailZero(y) < trailZero(4 * y):
		y *= 4
	print(y)


n = int(input())
a = list(map(int, input().split()))
for i in a:
	ans = i
	while True:
		while ans % 10 == 0:
			ans = ans // 10
		if ans % 10 == 5:
			i *= 4
			ans = i
		else:
			print(i)
			break


t = int(input())
a = list(map(int, input().split()))
i = 0
while i < t:
	if a[i] % 10 == 0:
		n = a[i]
		while n % 10 == 0:
			n /= 10
		while n % 10 != 0 and n % 5 == 0:
			a[i] *= 4
			n = a[i]
			n / 10
			while n % 10 == 0:
				n /= 10
		print(a[i])
	elif a[i] % 5 == 0:
		n = a[i]
		while n % 10 != 0 and n % 5 == 0:
			a[i] *= 4
			n = a[i]
			n / 10
			while n % 10 == 0:
				n /= 10
		print(a[i])
	else:
		print(a[i])
	i += 1


import sys

def ceros(value):
	cont = 0
	while value % 10 == 0:
		value /= 10
		cont += 1
	return cont
n = int(input())
line = input()
A = [int(x) for x in line.split()]
for value in A:
	while ceros(value) < ceros(value * 4):
		value *= 4
	print(value)


n = int(input())
a = [int(word) for word in input().split()]
for ai in a:
	orgai = ai
	pow2 = 0
	pow5 = 0
	mult2 = 1
	while ai % 5 == 0:
		ai //= 5
		pow5 += 1
	while ai % 2 == 0:
		ai //= 2
		pow2 += 1
	if pow2 < pow5:
		mult2 = 2 ** (2 * ((pow5 - pow2 + 1) // 2))
	print(orgai * mult2)


import sys
from itertools import *
from pprint import pprint

def find(n):
	zs = 0
	while 1:
		while n % 10 == 0:
			zs += 1
			n //= 10
		if n % 5:
			break
		n *= 4
	for i in range(zs):
		n *= 10
	return n

def solve():
	N = int(sys.stdin.readline())
	NS = tuple((int(x) for x in sys.stdin.readline().split()))
	assert len(NS) == N
	for n in NS:
		print(int(find(n)))

def perr(*ns):
	pprint(ns, stream=sys.stderr)
solve()


n = int(input())
l = list(map(int, input().split()))
m = []
for i in l:
	if i % 5 != 0:
		m.append(i)
	else:
		k = i
		p = i
		c1 = 0
		c2 = 0
		while k % 5 == 0:
			c1 += 1
			k //= 5
		while p % 2 == 0:
			c2 += 1
			p //= 2
		if c2 >= c1:
			m.append(i)
		else:
			m.append(i * 4 ** ((c1 - c2 + 1) // 2))
for j in m:
	print(j, end='\n')


shit = []
for i in range(13):
	shit.append(4 ** ((i + 1) // 2))

def five_pow(x):
	ans = 0
	while x % 5 == 0:
		x //= 5
		ans += 1
	return ans

def two_pow(x):
	ans = 0
	while x % 2 == 0:
		x //= 2
		ans += 1
	return ans
N = int(input())
A = [int(x) for x in input().split()]
for x in A:
	y = five_pow(x) - two_pow(x)
	if y > 0:
		print(x * shit[y])
	else:
		print(x)


def check(a):
	s = str(a)
	for i in range(len(s) - 1, -1, -1):
		if s[i] != '0' and s[i] != '5':
			return 0
		elif s[i] == '5':
			return 1
n = int(input())
s = input()
a = [int(i) for i in s.split()]
for i in range(n):
	while 1:
		if check(a[i]):
			a[i] = a[i] * 4
		else:
			break
	print(a[i])


t = int(input())
count = 0
value = 1
l = []
summ = 0
l.append(input().split())
length = len(l[0])
for i in range(length):
	a = int(l[0][i])
	b = int(l[0][i])
	while a % 10 == 0:
		count = count + 1
		a = a // 10
	while a % 5 == 0:
		summ = summ + 1
		a = a // 5
	k = summ // 2 + summ % 2
	for z in range(k):
		b = 4 * b
	for y in range(count):
		value = value * 10
	print(b)
	count = 0
	value = 1
	summ = 0


import math

def power_num(num, div):
	i = 0
	tmp = div
	while num % div == 0:
		div = div * tmp
		i = i + 1
	return i
n = int(input())
nums = [int(x) for x in input().split()]
ans = []
for i in nums:
	div5 = power_num(i, 5)
	div2 = power_num(i, 2)
	if div5 <= div2:
		ans.append(i)
	else:
		p = math.ceil((div5 - div2) / 2)
		ans.append(i * 4 ** p)
for i in ans:
	print(i)


n = int(input())
a = []
a.extend(input().split())
a = list(map(lambda x: int(x), a))
for i in range(n):
	p = a[i]
	cunt = 0
	k = p
	while k % 10 == 0:
		k = k / 10
	while k % 5 == 0:
		k = k / 5
		cunt = cunt + 1
	if cunt == 0:
		print(p)
	elif cunt <= 2:
		print(p * 4)
	elif cunt <= 4:
		print(p * 4 * 4)
	elif cunt <= 6:
		print(p * 4 * 4 * 4)
	elif cunt <= 8:
		print(p * 4 * 4 * 4 * 4)
	elif cunt <= 10:
		print(p * 4 * 4 * 4 * 4 * 4)
	else:
		print(p * 4 * 4 * 4 * 4 * 4 * 4)


def func(x):
	tempx = x
	(n2, n5) = (0, 0)
	while x % 2 == 0:
		x = x // 2
		n2 += 1
	x = tempx
	while x % 5 == 0:
		x = x // 5
		n5 += 1
	ans = max(0, n5 - n2)
	if ans % 2:
		ans += 1
	return ans // 2
n = int(input())
lst = [int(x) for x in input().strip().split()]
lst = map(lambda x: x * pow(4, func(x)), lst)
for item in lst:
	print(item)


def count_zeroes_at_end(num):
	num = list(str(num))
	ans = 0
	while num and num[-1] == '0':
		ans += 1
		num.pop()
	return ans
tests = int(input())
num_arr = list(map(int, input().split()))
for num in num_arr:
	ans = num
	temp = ans * 4
	while count_zeroes_at_end(temp) > count_zeroes_at_end(ans):
		ans = temp
		temp *= 4
	print(ans)


m = 10 ** 22

def trailingZeroes(n):
	c = 0
	while n > 0 and n % 10 == 0:
		n //= 10
		c += 1
	return c

def magicNum(n):
	if n % 5 != 0:
		return n
	a = [n]
	while n < m:
		a.append(n * 4)
		n *= 4
	d = {}
	for i in a:
		d[i] = trailingZeroes(i)
	(p, r) = (0, 0)
	for i in d:
		if d[i] > r:
			r = d[i]
			p = i
		elif d[i] == r and i < p:
			p = i
	return p
t = int(input())
t -= 1
a = list(map(int, input().split()))
for i in a:
	print(magicNum(i))


def pr2(n):
	count = 0
	while n % 2 == 0:
		count += 1
		n = n / 2
	return count

def pr(n):
	count = 0
	while n % 5 == 0:
		count += 1
		n = n / 5
	return count
n = int(input())
num4 = 0
a = input().split()
a = [int(x) for x in a]
for i in a:
	x = pr(i)
	y = pr2(i)
	x -= y
	if x > 0:
		num4 = x // 2
		if x % 2:
			num4 += 1
		while num4:
			(i, num4) = (i * 4, num4 - 1)
	print(i)


dummy = input()
a = input().split()
n = len(a)
for i in range(n):
	k = int(a[i])
	d = k
	j = 0
	while d % 5 == 0:
		d = d // 5
		j += 1
	d = k
	m = 0
	while d % 10 == 0:
		d = d // 10
		m += 1
	jm = j - m
	if jm == 0:
		print(k)
	else:
		if jm % 2 == 0:
			ans = int(k * 4 ** (jm / 2))
		else:
			ans = int(k * 4 ** (jm // 2 + 1))
		print(ans)


n = int(input())
a = []
a = input().split()
for i in a:
	c = 0
	while 1:
		if i[len(i) - 1] == '5':
			i = str(int(i) * 4)
		elif i[len(i) - 1] == '0':
			i = str(int(i) // 10)
			c = c + 1
		else:
			break
	if c == 0:
		print(i)
	else:
		print(int(i) * pow(10, c))


def main():
	n = int(input())
	a = [int(x) for x in input().split()]
	for x in a:
		e5 = 0
		y = x
		while y % 5 == 0:
			e5 += 1
			y //= 5
		e2 = 0
		y = x
		while y % 2 == 0:
			e2 += 1
			y //= 2
		n_twos_needed = max(e5 - e2, 0)
		n4 = n_twos_needed // 2 + n_twos_needed % 2
		print(x * 4 ** n4)
main()


n = int(input())
l = list(map(int, input().split()))
for x in l:
	count = 0
	t = x
	while t % 10 == 0:
		t = t // 10
	while t % 5 == 0:
		count += 1
		t = t // 5
	if count % 2 == 0:
		print(x * pow(4, count // 2))
	else:
		print(x * pow(4, (count + 1) // 2))


from math import log

def soln(n, arr):
	res = []
	for i in arr:
		twos = 0
		cur = i
		while cur % 2 == 0:
			twos += 1
			cur //= 2
		fives = 0
		cur = i
		while cur % 5 == 0:
			fives += 1
			cur //= 5
		for x in range(0, fives - twos, 2):
			i *= 4
		res.append(i)
	return res
n = int(input())
arr = list(map(int, input().split()))
for i in soln(n, arr):
	print(i)


import math
n = input()
q = input()
q = q.rstrip(' ')
q = q.split(' ')
s = list(map(int, q))
for i in range(len(s)):
	flag = 0
	while flag == 0:
		temp = s[i]
		x = temp % 10
		while x == 0:
			x = temp % 10
			temp = temp / 10
		if x != 5:
			break
		else:
			s[i] = s[i] * 4
	print(s[i])


import math
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	e = a[i]
	fi = 0
	while e % 5 == 0:
		e = e // 5
		fi += 1
	two = 0
	while e % 2 == 0:
		e = e // 2
		two += 1
	if two >= fi:
		print(a[i])
	else:
		w = fi - two
		print(a[i] * 4 ** math.ceil(w / 2))


def main(n):
	string = str(n)
	length = len(string)
	count = 0
	for i in range(length - 1, -1, -1):
		if string[i] == '0':
			count += 1
		else:
			break
	final = int(string[0:length - count])
	degree = 0
	while final % 5 ** (degree + 1) == 0:
		degree += 1
	if degree % 2 == 0:
		return n * 4 ** (degree // 2)
	return n * 4 ** ((degree + 1) // 2)
n = int(input())
array = list(map(int, input().split()))
for i in array:
	print(main(i))


def ans(val):
	count = 0
	while val != 0:
		x = val % 10
		if x != 0:
			break
		count += 1
		val //= 10
	return count
n = int(input())
a = list(map(int, input().split()))
for num in a:
	x = num
	last = ans(x)
	while 1:
		temp = x * 4
		a2 = ans(temp)
		if a2 > last:
			last = a2
			x = temp
			continue
		else:
			break
	print(x)


n = int(input())
l = [int(x) for x in input().split()]
for i in range(n):
	while True:
		no = l[i]
		while no % 10 == 0:
			no //= 10
		if no % 10 == 5:
			l[i] = l[i] * 4
		else:
			break
	print(l[i])


n = int(input())
numbers = list(map(int, input().split()))
for test_case in range(0, n):
	current_num = numbers[test_case]
	manipulator = numbers[test_case]
	count5 = 0
	while current_num % 5 == 0:
		count5 += 1
		current_num = current_num / 5
	count2 = 0
	while current_num % 2 == 0:
		count2 += 1
		current_num = current_num / 2
	if count2 < count5:
		difference = count5 - count2
		if difference % 2 == 0:
			magicstones = int(difference / 2)
		else:
			magicstones = int((difference + 1) / 2)
		for i in range(0, magicstones):
			manipulator = manipulator * 4
		print(manipulator)
	else:
		print(manipulator)


p = int(input())
k = input().split()
for l in k:
	n = int(l)
	k = n
	temp = 1
	while n % 5 == 0:
		temp += 1
		n = n // 5
	while n % 2 == 0:
		temp -= 1
		n = n // 2
	temp = temp // 2
	for y in range(temp):
		k = k * 4
	print(k)


def main():
	n = int(input())
	numbers = list(map(int, input().split()))
	for num in numbers:
		r = num % 10
		cpy = num
		while r == 0:
			num /= 10
			r = num % 10
		if r == 5:
			while r == 5:
				cpy = cpy * 4
				num = num * 4
				r = num % 10
				while r == 0:
					num /= 10
					r = num % 10
		print(cpy)
main()


input()
nums = list(map(int, input().split()))
for n in nums:
	tens = 0
	while n % 10 == 0:
		tens += 1
		n //= 10
	while n % 25 == 0:
		tens += 2
		n = n // 25
	while n % 5 == 0:
		tens += 1
		n = n // 5 * 2
	print(n * 10 ** tens)


def ans(n):
	ans = 0
	while n > 0:
		if n % 10 == 0:
			ans += 1
		else:
			break
		n /= 10
	return ans
n = int(input())
a = list(map(int, input().split()))
for i in a:
	if i % 5 == 0:
		x = i
		while ans(x) != ans(4 * x):
			x *= 4
		print(x)
	else:
		print(i)


n = int(input())
t = input().split()
t = list(map(int, t))
for i in range(n):
	if t[i] % 5 != 0:
		print(t[i])
	elif t[i] % 10 == 0:
		p = str(t[i])
		p = p.replace('0', '')
		if p[len(p) - 1] != '5':
			print(t[i])
		else:
			while p[len(p) - 1] == '5':
				t[i] = t[i] * 4
				p = str(t[i])
				p = p.replace('0', '')
			print(t[i])
	else:
		q = t[i] * 4
		p = str(q)
		p = p.replace('0', '')
		while p[len(p) - 1] == '5':
			q = q * 4
			p = str(q)
			p = p.replace('0', '')
		print(q)


import sys
t = int(sys.stdin.readline())
arr = [int(x) for x in sys.stdin.readline().split()]
for n in arr:
	a = n
	x = 10
	while a % x == 0:
		x *= 10
	while a % x == x / 2:
		a *= 4
		while a % x == 0:
			x *= 10
	print(a)


n = int(input())
a = []
z = []
s = input()
a = [int(i) for i in s.split()]
for i in range(n):
	t = 1
	f = a[i]
	ff = f * 4
	while t == 1:
		s1 = str(f)
		s2 = str(ff)
		len1 = len(s1) - len(s1.rstrip('0'))
		len2 = len(s2) - len(s2.rstrip('0'))
		if len2 > len1 and len2 != len1:
			f = ff
			ff = ff * 4
		else:
			break
	print(f)


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	min1 = 0
	min2 = 0
	s1 = a[i]
	s2 = str(a[i])
	while 1:
		tst = s1
		tst = str(tst * 4)
		temp = 0
		for j in range(len(tst) - 1, -1, -1):
			if tst[j] != '0':
				break
			temp += 1
		if temp == min1:
			break
		else:
			s1 = int(tst)
			min1 = temp
	for j in range(len(s2) - 1, -1, -1):
		if s2[j] != '0':
			break
		min2 += 1
	if min2 >= min1:
		print(s2)
	else:
		print(s1)


a = int(input())
b1 = input()
b = [int(n) for n in b1.split()]
s = 0
s1 = 0
for i in range(a):
	f = b[i]
	s = 0
	while f % 5 == 0:
		s += 1
		f = f / 5
	f = b[i]
	s1 = 0
	while f % 2 == 0:
		s1 += 1
		f = f / 2
	if s1 < s:
		s = s - s1
		if s > 0:
			s = int(s / 2 + s % 2)
		b[i] = b[i] * 4 ** s
for i in range(a):
	print(b[i])


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	if a[i] % 5 == 0:
		while int(str(a[i]).rstrip('0')) % 5 == 0:
			a[i] *= 4
		print(a[i])
	else:
		print(a[i])


n = int(input())

def chk1(b):
	flag1 = 0
	while b % 10 == 0:
		flag1 += 1
		b = b // 10
	return flag1

def chk(a):
	flag = 0
	while int(a % 5) == 0:
		flag += 1
		a = a // 5
	return flag
l = []
l.append(input().split())
l = l[0]
l = list(map(lambda x: int(x), l))
for i in l:
	k = chk1(i)
	j = i // 10 ** k
	p = chk(j)
	if p == 0:
		print(i)
	elif p <= 2:
		print(i * 4)
	elif p <= 4:
		print(i * 4 * 4)
	elif p <= 6:
		print(i * 4 * 4 * 4)
	elif p <= 8:
		print(i * 4 * 4 * 4 * 4)
	elif p <= 10:
		print(i * 4 * 4 * 4 * 4 * 4)
	else:
		print(i * 4 * 4 * 4 * 4 * 4 * 4)


def main():
	cases = int(input())
	nums = [int(x) for x in input().split()]
	for n in nums:
		while True:
			stripped = stripZeroes(n)
			if stripped % 5 == 0 or stripped % 10 == 0:
				n *= 4
			else:
				break
		print(n)

def stripZeroes(n):
	while n % 10 == 0:
		n /= 10
	return n
main()


input()
S = input().split()
for ss in S:
	n = int(ss)
	x = n
	k = 0
	while (x > 0) & (x % 10 == 0):
		x //= 10
	while (x > 0) & (x % 5 == 0):
		k += 1
		x //= 5
	print(n * 4 ** ((k + 1) // 2))


def solve(a):
	for v in a:
		i = 0
		w = v
		while w % 10 == 0:
			w //= 10
		while w % 5 == 0:
			w //= 5
			i += 1
		print(v * 4 ** ((i + 1) // 2))
input()
solve(list(map(int, input().split())))


n = int(input())
arr = input().split()
arr = [int(i) for i in arr]
for x in arr:
	(two, five) = (0, 0)
	temp = x
	while temp % 2 == 0:
		temp = temp / 2
		two += 1
	temp = x
	while temp % 5 == 0:
		temp = temp / 5
		five += 1
	ans = -1
	if five != 0:
		twoReq = five - two
		if twoReq > 0:
			ans = x * 4 ** int((twoReq + 1) / 2)
		else:
			ans = x
	else:
		ans = x
	print(ans)


def trailing_zeroes(a, i, j):
	value = str(int(a[i]) * 4)
	while 1:
		j = last_num(value)
		if value[-j] != '5':
			print(value)
			break
		elif value[-j] == '5':
			value = str(int(value) * 4)

def last_num(value):
	for j in range(1, len(value) + 1):
		if value[-j] != '0':
			return j
n = int(input())
a = [x for x in input().split()]
for i in range(len(a)):
	if a[i][-1] != '5' and a[i][-1] != '0':
		print(a[i])
	else:
		j = last_num(a[i])
		if a[i][-j] != '5':
			print(a[i])
		elif a[i][-j] == '5':
			trailing_zeroes(a, i, j)


n = input()
arr_nos = input()
arr_nos = arr_nos.strip()
list_nos = arr_nos.split(' ')
for str_element in list_nos:
	element = int(str_element)
	count_four = 0
	count_five = 0
	loop_element = element
	while loop_element % 5 == 0:
		count_five += 1
		loop_element = loop_element / 5
	element = int(str_element)
	count_two = 0
	loop_element = element
	while loop_element % 2 == 0:
		count_two += 1
		loop_element = loop_element / 2
	element = int(str_element)
	value = element
	while count_two < count_five:
		value = value * 4
		count_two += 2
	print(value)


from math import ceil
n = int(input())
a = [int(i) for i in input().split()]
for x in a:
	x2 = x
	fives = 0
	while x2 % 5 == 0:
		x2 /= 5
		fives += 1
	twos = 0
	while x2 % 2 == 0:
		x2 /= 2
		twos += 1
	y = int(x * 4 ** max(0, ceil((fives - twos) / 2)))
	print(y)


def z(n, p):
	a = 0
	while n % p == 0:
		n //= p
		a += 1
	return a
input()
for x in input().split():
	t = b = int(x)
	while t % 10 == 0:
		t //= 10
	k = z(t, 5)
	for _ in range((k + 1) // 2):
		b *= 4
	print(b)


def max_pow(n, k):
	cnt = 0
	while n % k == 0:
		n //= k
		cnt += 1
	return cnt
n = int(input())
for i in input().split():
	x = int(i)
	pow10 = max_pow(x, 10)
	pow5 = max_pow(x, 5) - pow10
	if pow5 % 2 != 0:
		pow5 += 1
	print(x * 2 ** pow5)


from math import ceil
n = int(input())
arr = list(map(int, input().split()))
for no in arr:
	copy = no
	c = 0
	c2 = 0
	while no % 5 == 0:
		no /= 5
		c += 1
	while no % 2 == 0:
		no /= 2
		c2 += 1
	if c == 0:
		print(copy)
	else:
		c = c - c2
		if c % 2 != 0:
			c += 1
		temp = c // 2
		for j in range(temp):
			copy *= 4
		print(copy)


t = int(input())
a = list(map(int, input().split()))
for i in range(0, t):
	count = 0
	temp = a[i]
	while temp % 10 == 0:
		temp = temp / 10
	while temp % 10 == 5 or temp % 100 == 25 or temp % 1000 == 125 or (temp % 1000 == 625) or (temp % 10000 == 3125) or (temp % 100000 == 15625) or (temp % 100000 == 78125) or (temp % 1000000 == 390625) or (temp % 10000000 == 1953125) or (temp % 10000000 == 9765625) or (temp % 100000000 == 48828125) or (temp % 1000000000 == 244140625):
		temp = temp * 4
		count = count + 1
		while temp % 10 == 0:
			temp = temp / 10
	te = pow(4, count)
	te = a[i] * te
	print(te)


n = int(input())
numbers = [int(x) for x in input().split()]
s = str(numbers)

def multiply(n):
	for c in reversed(n):
		ans = int(n)
		if c == '0':
			continue
		elif c == '5':
			while str(ans).rstrip('0')[-1] == '5':
				ans = ans * 4
			break
		else:
			break
	return str(ans)
for _ in range(n):
	print(multiply(str(numbers[_])))


from copy import deepcopy as dc
tCase = int(input())
allNumbers = [int(x) for x in input().split()]
for item in allNumbers:
	(copyValue, counterVar) = (dc(item), 0)
	while copyValue % 10 == 0:
		copyValue /= 10
	while copyValue % 5 == 0:
		copyValue /= 5
		counterVar += 1
	noof4sreqd = (counterVar + 1) // 2
	print(4 ** noof4sreqd * item)


n = int(input())
a = list(map(int, input().split()))
for i in range(len(a)):
	k = a[i]
	f = 0
	while f != 1:
		s = str(k)
		for j in range(len(s) - 1, -1, -1):
			if s[j] != '0':
				h = s[j]
				break
		if h != '5':
			ans = k
			f = 1
		else:
			k *= 4
	print(ans)


def trailingzeroes(nmbr):
	result = 0
	while nmbr != 0 and nmbr % 10 == 0:
		result += 1
		nmbr //= 10
	return result
_unused = input()
Ai = map(int, input().strip().split())
for a in Ai:
	z = trailingzeroes(a)
	while 1:
		a4 = a * 4
		z4 = trailingzeroes(a4)
		if z4 > z:
			(a, z) = (a4, z4)
		else:
			break
	print(a)


n = int(input())
A = list(map(int, input().split()))
L = []
S = 0
for n in A:
	cnt2 = 0
	cnt5 = 0
	(temp1, temp2, res) = (n, n, n)
	while temp1 % 2 == 0:
		cnt2 += 1
		temp1 //= 2
	while temp2 % 5 == 0:
		cnt5 += 1
		temp2 //= 5
	while cnt5 > cnt2:
		res *= 4
		cnt2 += 2
	print(res)