ภยา
Language: Russian
English

Remote Training on Programming

Problems Online status Contests
News FAQ E-learning
For authors:
Register  ||  Login
 
Hello, Guest! Please login or register.

1142. GCDs

Time Limit: 1 seconds
Memory Limit:65536KB
Points:100
View Problem Statistics Submit Problem added debug

Schoolboy Vasya is toying with numbers. He chooses n distinct positive integers a1, a2, …, an in ascending order and calculates the greatest common denominators (GCD) for all pairs <ai, aj> with i < j, writing down the results in a table. For example, numbers 1, 2, 3, 4, 5, 6, 7, 8 will produce the following GCD table:

                            1: 1, 1, 1, 1, 1, 1, 1

                            2: 1, 2, 1, 2, 1, 2

                            3: 1, 1, 3, 1, 1

                            4: 1, 2, 1, 4

                            5, 1, 1, 1

                            6: 1, 2

                            7: 1

                            8:

Obviously, several sequences can produce the same GCD table, thus in general it is impossible to restore the exact original sequence using only the GCD table. Write a program that, given the GCD table, will restore a possible initial sequence a1, a2, …, an. If several such sequences exist then any of them will be considered as a correct answer.

 

Limitations

1 <= n <= 100; 1 <= ai <= 109; 1 <= GCD(ai , aj) <= 104.

 

Input

The first line contains an integer n, the number of integers in the sequence. The following n–1 lines describe the rows of the GCD table for a1, a2, …, an–1, respectively. The line for ai contains n–i integers separated by spaces: GCD(ai, ai+1),  GCD(ai, ai+2), …, GCD(ai, an). You can safely assume that the input data is based on some real sequence a1, a2, a3, …, an, which means that a solution always exists.

 

Output

The output file should contain n space-delimited integers: possible initial numbers a1, a2, …, an, respectively.

 

Example

Input

Output

4

4 4 2

4 2

6

4 8 12 18

 

Input

Output

4

2 2 2

2 2

2

2 6 8 10

 

 

All Rybinsk-2012 problems (in PDF)


View Problem Statistics Submit Problem discussion Author/source:
Problems from Contests and Camps / World Championship in Programming (ICPC) / Rybinsk-2012 /
1141. E - Multiplication puzzle 1142. 1143. G - Function 1144. H - Milestones 1145. I - Dunno
time generating 0.094 sec.
ฉ Copyright VSU, AVT, Nosov D.A., Andrianov I.A.