#ABC289B. [ABC289B] レ

[ABC289B] レ

Score : 200200 points

Problem Statement

Studying Kanbun

, Takahashi is having trouble figuring out the order to read words. Help him out!

There are NN integers from 11 through NN arranged in a line in ascending order.
Between them are MM "レ" marks. The ii-th "レ" mark is between the integer aia_i and integer (ai+1)(a_i + 1).

You read each of the NN integers once by the following procedure.

  • Consider an undirected graph GG with NN vertices numbered 11 through NN and MM edges. The ii-th edge connects vertex aia_i and vertex (ai+1)(a_i+1).
  • Repeat the following operation until there is no unread integer:- let xx be the minimum unread integer. Choose the connected component CC containing vertex xx, and read all the numbers of the vertices contained in CC in descending order.
  • let xx be the minimum unread integer. Choose the connected component CC containing vertex xx, and read all the numbers of the vertices contained in CC in descending order.

For example, suppose that integers and "レ" marks are arranged in the following order:

image

(In this case, N=5,M=3N = 5, M = 3, and a=(1,3,4)a = (1, 3, 4).) Then, the order to read the integers is determined to be 2,1,5,42, 1, 5, 4, and 33, as follows:

  • At first, the minimum unread integer is 11, and the connected component of GG containing vertex 11 has vertices {1,2}\lbrace 1, 2 \rbrace, so 22 and 11 are read in this order.
  • Then, the minimum unread integer is 33, and the connected component of GG containing vertex 33 has vertices {3,4,5}\lbrace 3, 4, 5 \rbrace, so 55, 44, and 33 are read in this order.
  • Now that all integers are read, terminate the procedure.

Given N,MN, M, and (a1,a2,,aM)(a_1, a_2, \dots, a_M), print the order to read the NN integers.

What is a connected component?

A subgraph of a graph is a graph obtained by choosing some vertices and edges from the original graph.
A graph is said to be connected if and only if one can travel between any two vertices in the graph via edges.
A connected component is a connected subgraph that is not contained in any larger connected subgraph.

Constraints

  • 1N1001 \leq N \leq 100
  • 0MN10 \leq M \leq N - 1
  • 1a1<a2<<aMN11 \leq a_1 \lt a_2 \lt \dots \lt a_M \leq N-1
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN MM

a1a_1 a2a_2 \dots aMa_M

Output

Print the answer in the following format, where pip_i is the ii-th integers to read.

p1p_1 p2p_2 \dots pNp_N

5 3
1 3 4
2 1 5 4 3

As described in the Problem Statement, if integers and "レ" marks are arranged in the following order:

image

then the integers are read in the following order: 2,1,5,42, 1, 5, 4, and 33.

5 0
1 2 3 4 5

There may be no "レ" mark.

10 6
1 2 3 7 8 9
4 3 2 1 5 6 10 9 8 7