{"problem":{"name":"V","description":{"content":"> Studying [_Kanbun_](https://en.wikipedia.org/wiki/Kanbun), Takahashi is having trouble figuring out the order to read words. Help him out! There are $N$ integers from $1$ through $N$ arranged in a ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc289_b"},"statements":[{"statement_type":"Markdown","content":"> Studying [_Kanbun_](https://en.wikipedia.org/wiki/Kanbun), Takahashi is having trouble figuring out the order to read words. Help him out!\n\nThere are $N$ integers from $1$ through $N$ arranged in a line in ascending order.  \nBetween them are $M$ \"レ\" marks. The $i$\\-th \"レ\" mark is between the integer $a_i$ and integer $(a_i + 1)$.\nYou read each of the $N$ integers once by the following procedure.\n\n*   Consider an undirected graph $G$ with $N$ vertices numbered $1$ through $N$ and $M$ edges. The $i$\\-th edge connects vertex $a_i$ and vertex $(a_i+1)$.\n*   Repeat the following operation until there is no unread integer:\n    *   let $x$ be the minimum unread integer. Choose the connected component $C$ containing vertex $x$, and read all the numbers of the vertices contained in $C$ in descending order.\n\nFor example, suppose that integers and \"レ\" marks are arranged in the following order:\n![image](https://img.atcoder.jp/ghi/abc289_4328a29fa11f2f7fe51962c84eb3f7d8530b6a7eb40438a04b652a0771430765.jpg)\n(In this case, $N = 5, M = 3$, and $a = (1, 3, 4)$.)  \nThen, the order to read the integers is determined to be $2, 1, 5, 4$, and $3$, as follows:\n\n*   At first, the minimum unread integer is $1$, and the connected component of $G$ containing vertex $1$ has vertices $\\lbrace 1, 2 \\rbrace$, so $2$ and $1$ are read in this order.\n*   Then, the minimum unread integer is $3$, and the connected component of $G$ containing vertex $3$ has vertices $\\lbrace 3, 4, 5 \\rbrace$, so $5$, $4$, and $3$ are read in this order.\n*   Now that all integers are read, terminate the procedure.\n\nGiven $N, M$, and $(a_1, a_2, \\dots, a_M)$, print the order to read the $N$ integers.\nWhat is a connected component? A **subgraph** of a graph is a graph obtained by choosing some vertices and edges from the original graph.  \nA graph is said to be **connected** if and only if one can travel between any two vertices in the graph via edges.  \nA **connected component** is a connected subgraph that is not contained in any larger connected subgraph.\n\n## Constraints\n\n*   $1 \\leq N \\leq 100$\n*   $0 \\leq M \\leq N - 1$\n*   $1 \\leq a_1 \\lt a_2 \\lt \\dots \\lt a_M \\leq N-1$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n$a_1$ $a_2$ $\\dots$ $a_M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc289_b","tags":[],"sample_group":[["5 3\n1 3 4","2 1 5 4 3\n\nAs described in the Problem Statement, if integers and \"レ\" marks are arranged in the following order:\n![image](https://img.atcoder.jp/ghi/abc289_4328a29fa11f2f7fe51962c84eb3f7d8530b6a7eb40438a04b652a0771430765.jpg)\nthen the integers are read in the following order: $2, 1, 5, 4$, and $3$."],["5 0","1 2 3 4 5\n\nThere may be no \"レ\" mark."],["10 6\n1 2 3 7 8 9","4 3 2 1 5 6 10 9 8 7"]],"created_at":"2026-03-03 11:01:14"}}