Gửi bài giải

Điểm: 5,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://codeforces.com/problemset/problem/582/A
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Reference: Codeforces 582A — GCD Table

For an array of ~n~ positive integers:

~a_1, a_2, \ldots, a_n~

its GCD table is an ~n \times n~ table defined by:

~G_{i,j} = \gcd(a_i, a_j)~

You are given all ~n^2~ entries of the GCD table in an arbitrary order.

Restore an array that could have produced the given table.

Input

  • The first line contains one integer ~n~.
  • The second line contains ~n^2~ positive integers: all entries of the GCD table in an arbitrary order.

Output

  • Print ~n~ positive integers forming a valid original array.
  • If multiple valid arrays exist, print any of them.

Constraints

  • ~1 \le n \le 500~
  • ~1 \le G_{i,j} \le 10^9~
  • It is guaranteed that the input corresponds to at least one valid array.

Example 1

Input:

4
2 1 2 3 4 3 2 6 1 1 2 2 1 2 3 2

Output:

4 3 6 2

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.