#P7491. [2017年杭电多校]Inversion

[2017年杭电多校]Inversion

Inversion

Problem Description

Give an array A, the index starts from 1. Now we want to know Bi=maxijAjB_{i}= \max\limits_{i\nmid j}A_{j} , i2i \geq 2.

Input

The first line of the input gives the number of test cases T; T test cases follow. Each case begins with one line with one integer n : the size of array A. Next one line contains n integers, separated by space, ith number is AiA_{i}. Limits T20T \leq 20 2n1000002 \leq n \leq 100000 1Ai10000000001 \leq Ai \leq 1000000000 n700000\sum{n} \leq 700000

Output

For each test case output one line contains n-1 integers, separated by space, ith number is Bi+1B_{i+1}.

Sample Input

2
4
1 2 3 4
4
1 4 2 3

Sample Output

3 4 3
2 4 4

Source

2017 Multi-University Training Contest - Team 6

https://acm.hdu.edu.cn/showproblem.php?pid=6098