АВТ
Язык:

Дистанционный практикум по программированию

Задачи Online статус Соревнования
Новости Справка СДО
 
Здравствуйте, Гость! Войдите с паролем или зарегистрируйтесь.

1142. GCDs

Ограничение времени: 1 сек.
Ограничение памяти:65536 КБайт
Баллы:100
Статистика Послать на проверку Задачу добавил 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 ni 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)


Статистика Послать на проверку Обсуждение задачи Автор/источник:
Задачи с соревнований и сборов / Чемпионат мира по программированию (ICPC) / Рыбинск-2012 /
1141. E - Головоломка 1142. 1143. G - Функция 1144. H - Верстовые столбы 1145. I - Dunno
 
время генерации 0.094 сек.
© Copyright ВоГУ, АВТ, Носов Д.А., Андрианов И.А.