#K67537. Reversed Digits and GCD Puzzle

    ID: 32664 Type: Default 1000ms 256MiB

Reversed Digits and GCD Puzzle

Reversed Digits and GCD Puzzle

You are given several test cases. In each test case, a sequence of numbers is provided where each number has its digits reversed. Your task is to:

  • Reverse the digits of each number to recover the original number. (For example, reversing 321 yields 123.)
  • Calculate the greatest common divisor (GCD) of the recovered original numbers.

For example, if one test case is 3 321 431 239, you first reverse each number to obtain [123, 134, 932] and then compute the GCD of these numbers, which in this case is 1.

The answer for each test case should be output on its own line.

inputFormat

The input is read from standard input (stdin) in the following format:

T
L1 a1 a2 ... aL1
L2 b1 b2 ... bL2
... 

Here, T is the number of test cases. Each test case begins with an integer L representing the number of reversed numbers in that test case, followed by L space-separated integers.

outputFormat

For each test case, output a single line containing the greatest common divisor (GCD) of the original numbers after reversing their digits.

## sample
2
3 321 431 239
2 987 456
1

3

</p>