SP30755 ADAGCD - Ada and GCD

Description

Ada the Ladybug got interesting homework. She had to count gcd of a few numbers. As she is a great mathematician, she done it in meanwhile (in fact, she submited it during the class it was assigned in). The teacher was impressed so he gave Ada a bonus homework (for bonus points). It is same as previous one with a little difference - there are bigger numbers. Since the number are too large to be written as numbers, they are written as product of lesser numbers. Find their gcd.

Input Format

The first line of input consists of **2 , the number of numbers for which Ada wants to find their gcd.** Each of the next **N** lines contains an integer **1 followed by **M $ _{i} $** integers, **1 , the numbers whose product is the **i $ ^{th} $** number.**** The sum of all **M $ _{i} $** won't exceed **10 $ ^{6} $**

Output Format

Print the **gcd** on a single line. Since this number might be pretty big, output it modulo **10 $ ^{9} $ +7** (**1000000007**)