#K63652. Smallest Non-Negative Card Values

    ID: 31801 Type: Default 1000ms 256MiB

Smallest Non-Negative Card Values

Smallest Non-Negative Card Values

You are given several test cases. In each test case, you have a list of integers representing card values. You can perform an operation as many times as you like, replacing all card values with their greatest common divisor (GCD). The task is to compute the smallest non-negative value each card can have after performing the operations. Formally, for a list of card values \(a_1, a_2, \dots, a_n\), the answer is a list where every element is \(g = \gcd(a_1, a_2, \dots, a_n)\).

For example, for the list [15, 20, 25, 30], the gcd is \(5\), so the output should be [5, 5, 5, 5].

Note: The input format is such that the first line contains the number of test cases. For each test case, the first line contains an integer \(N\) representing the number of cards, followed by a line containing \(N\) space-separated integers.

inputFormat

The input is read from standard input. The structure is as follows:

  1. The first line contains an integer \(T\), the number of test cases.
  2. For each test case:
    1. A line containing a single integer \(N\) (the number of cards).
    2. A line with \(N\) space-separated integers representing the card values.

outputFormat

For each test case, output a line containing \(N\) space-separated integers, each equal to the GCD of the corresponding test case's card values.

The result is printed to standard output.

## sample
1
4
15 20 25 30
5 5 5 5