t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split()))[1:] if a.count(0) == n-1: print(1) continue cnt2 = [0]*(n-1) cnt5 = [0]*(n-1) for i in range(n-1): while a[i] % 10 == 0 and a[i] != 0: a[i] //= 10 while a[i] % 2 == 0 and a[i] != 0: cnt2[i] += 1 a[i] //= 2 while a[i] % 5 == 0 and a[i] != 0: cnt5[i] += 1 a[i] //= 2 print(10**(max(max(cnt2), max(cnt5))+1)//2**max(cnt2)//5**max(cnt5))