You are on page 1of 2

Coderun 04 - The Revival  

  Mar 14, 2023

Problem B. Can you find me!


Time limit 1000 ms
Code length Limit 50000 B
OS Linux

Shahid has created a complex machine that takes in a sequence A = [A1 , A2 , … , AN ] and
​ ​ ​

produces a sequence B = [B1 , B2 , … , BN ] such that for each valid i, Bi is the largest index j
​ ​ ​ ​

such that Aj divides Ai (including itself). For instance, if the input sequence is A = [2, 6, 3, 12],
​ ​

the machine will produce B = [4, 4, 4, 4].


Now, Shahid has given you a sequence B that was produced by the machine, and she wants you
to find an integer sequence A such that when fed into the machine, it produces B . However,
Alice doesn't like large integers, so make sure that 1 ≤ Ai ≤ 4 ⋅ 106 holds for each valid i.

Input

The first line contain T denoting the number of test cases.


The first line of each test case contains N .
The second line contains N space-separated integers representing Bi ​

Output

For each test case, print N space-separated integers representing Ai . For each valid i, 1
​ ≤ Ai ≤

4 ⋅ 106 should hold.

If there are multiple solutions, you may print any of them. It is guaranteed that at least one
solution exists.

Constraints

1 ≤ T ≤ 2 ⋅ 104
1 ≤ N ≤ 105
1 ≤ Bi ≤ N for each valid i

the sum of N over all test cases does not exceed 2 ⋅ 105

Sample 1

-
Coderun 04 - The Revival    Mar 14, 2023

Input Output

2 3 5 7 4 10
5 2 3 8 9
1 5 3 4 5
4
3 4 3 4

You might also like