Gayasen has received a homework assignment to compute the greatest common divisor of the two positive integers A and B. Since the numbers are quite large, the professor provided him with N smaller integers whose product is A, and M integers with product B.
He would like to verify result, so he has asked you to write a program to solve his problem. But instead of printing complete answer you have to print answer modulo 109+7.
First line of input contains the positive integer N (1 <= N <= 1000).
Second line of input contains N space-separated positive integers not greater than 104, whose product is the number A.
Third line of input contains the positive integer M (1 <= M <= 1000).
Fourth line of input contains M space-separated positive integers not greater than 104, whose product is the number B.
Print the greatest common divisor of numbers A and B modulo 1000000007.
1 <= N, M <= 1000
1 <= element of list <= 10000
Explanation Sample Case #00: Here A = 2×2×3×3×25 = 900, while B = 8×1×6×170 = 8160. Greatest common divisor of 900 and 8160 is 60. Sample Case #01: In first list all number are of form 2^a and in second they are of form 3^a. As these two list doesn't share any factor, their gcd is 1. Sample Case #02: The greatest common divisor of numbers A(=30) and B(=20) equals 10.