Ghost Leg

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

A Ghost Leg is a method for representing permutations.

A Ghost Leg can be represented as a set of vertical lines, each line corresponding to one element of the set being permuted. Horizontal lines (like the rungs of a ladder) connect adjacent vertical lines in such a way that no two rungs share an endpoint. An example is shown in the illustration to the right.

To determine the resulting position of any element under a Ghost Leg permutation, begin at the top of the vertical line corresponding to that element. Trace a path down the line until encountering the first rung touching that line. Follow that rung to the adjacent vertical line. It does not matter whether the rung goes to the left or to the right, just follow it. Continue downward, following rungs, until reaching the bottom. This gives the final position of that element under the permutation.

In the example, element 22 ends up third in the permutation. The path is shown with red dotted lines. Likewise, element 11 ends up fourth, element 33 ends up first, and element 44 ends up second.

Given a description of a Ghost Leg, determine the result of the permutation. In other words, apply the specified permutation, and output the elements in their permuted order.

입력

The first line of input contains two positive integers nn (1n1001 \le n \le 100) and mm (0m1,0000 \le m \le 1{,}000), where nn is the number of elements being permuted, and mm is the number of rungs. The vertical lines (elements) are identified from left to right by the integers 11 through nn.

Each of the next mm lines contains a single integer aa (1a<n1 \le a < n), which indicates that there is a rung between vertical lines aa and a+1a+1. The rungs are listed in order from top to bottom of the Ghost Leg. Clearly, no two rungs can be at the same height.

출력

Output nn lines, where each line contains a single integer. This is the resulting permutation. The first line is the element that ends up first in the permutation, the second is the element that ends up second, and so on.