PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000101. Shohag yêu thích ƯCLN (Shohag Loves GCD)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Shohag yêu thích ƯCLN (Shohag Loves GCD)

Shohag Loves GCD

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given a positive integer nn and a strictly increasing set SS of mm distinct positive integers, construct the lexicographically largest array a1,…,ana_1,\ldots,a_n with every ai∈Sa_i\in S such that agcd⁡(i,j)≠gcd⁡(ai,aj)a_{\gcd(i,j)}\ne\gcd(a_i,a_j) for every pair 1≤i<j≤n1\le i<j\le n. If no such array exists, print -1.

Input

The first line contains n,mn,m. The second line contains the mm elements of SS in increasing order.

Output

Print -1 if impossible; otherwise print exactly nn elements of the lexicographically largest valid array.

Subtasks

  • Subtask 1 (20 points): 1≤m≤n≤151\le m\le n\le 15; 1≤si≤n1\le s_i\le n.
  • Subtask 2 (30 points): 1≤m≤n≤30001\le m\le n\le 3000; 1≤si≤n1\le s_i\le n.
  • Subtask 3 (50 points): 1≤m≤n≤1051\le m\le n\le 10^5; 1≤si≤n1\le s_i\le n.

Examples

Input

6 3
3 4 6

Output

6 4 4 3 4 3

Explanation

The lexicographically largest valid array is 6 4 4 3 4 3, using only elements from SS. For example, (i,j)=(2,3)(i,j)=(2,3) gives agcd⁡(2,3)=a1=6a_{\gcd(2,3)}=a_1=6 while gcd⁡(a2,a3)=4\gcd(a_2,a_3)=4. All other pairs are valid as well.