P22210 [CodeChef] PREFPERM
普及
题目描述

You are given an array A of length K. Find any permutation P of length N such that only the prefixes of length A_{i} (1 ≤ i ≤ K) form a permutation.

Under the given constraints, it is guaranteed that there exists at least one permutation which satisfies the given condition.

If there are multiple solutions, you may print any.

Note: A permutation of length N is an array where every element from 1 to N occurs exactly once.

------ Input Format ------

  • The first line of the input contains a single integer T - the number of test cases.
  • The first line of each test case contains two integers N and K - the length of the permutation to be constructed and the size of the array A respectively.
  • The second line of each test case contains $K space-separated integers A_{1}, A_{2}, \dots, A_{K}$ denoting the array A.

------ Output Format ------

For each test case, print $a single line containing N space-separated integers P_{1}, \dots, P_{N} (1$ ≤ P_{i} ≤ N). If there are multiple solutions, you may print any.

------ Constraints ------

$1 ≤T ≤10^{5}$
$1 ≤K ≤N ≤10^{5}$
$1 ≤A_{1} < A_{2} < \dots < A_{K} = N$
- the sum of $N$ over all test cases does not exceed $5 \cdot 10^{5}$

----- Sample Input 1 ------
3
8 4
3 6 7 8
7 1
7
5 5
1 2 3 4 5

----- Sample Output 1 ------
2 3 1 6 4 5 7 8
4 6 1 5 2 7 3
1 2 3 4 5
----- explanation 1 ------
Test case-1: $[2, 3, 1, 6, 4, 5, 7, 8]$ is valid permutation because
- Prefix of length $3 = [2, 3, 1]$ is a permutation.
- Prefix of length $6 = [2, 3, 1, 6, 4, 5]$ is a permutation.
- Prefix of length $7 = [2, 3, 1, 6, 4, 5, 7]$ is a permutation.
- Prefix of length $8 = [2, 3, 1, 6, 4, 5, 7, 8]$ is a permutation.
- None of the other prefixes form a permutation.

输入格式

见题面

输出格式

见题面

样例输入
3 8 4 3 6 7 8 7 1 7 5 5 1 2 3 4 5
样例输出
2 3 1 6 4 5 7 8 4 6 1 5 2 7 3 1 2 3 4 5