#ABC250C. [ABC250C] Adjacent Swaps

[ABC250C] Adjacent Swaps

Score : 300300 points

Problem Statement

NN balls are lined up in a row from left to right. Initially, the ii-th (1iN1 \leq i \leq N) ball from the left has an integer ii written on it.

Takahashi has performed QQ operations. The ii-th (1iQ1 \leq i \leq Q) operation was as follows.

  • Swap the ball with the integer xix_i written on it with the next ball to the right. If the ball with the integer xix_i written on it was originally the rightmost ball, swap it with the next ball to the left instead.

Let aia_i be the integer written on the ii-th (1iN1 \leq i \leq N) ball after the operations. Find a1,,aNa_1,\ldots,a_N.

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 1Q2×1051 \leq Q \leq 2 \times 10^5
  • 1xiN1 \leq x_i \leq N
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN QQ

x1x_1

\vdots

xQx_Q

Output

Print a1,,aNa_1,\ldots,a_N, with spaces in between.

5 5
1
2
3
4
5
1 2 3 5 4

The operations are performed as follows.

  • Swap the ball with 11 written on it with the next ball to the right. Now, the balls have integers 2,1,3,4,52,1,3,4,5 written on them, from left to right.
  • Swap the ball with 22 written on it with the next ball to the right. Now, the balls have integers 1,2,3,4,51,2,3,4,5 written on them, from left to right.
  • Swap the ball with 33 written on it with the next ball to the right. Now, the balls have integers 1,2,4,3,51,2,4,3,5 written on them, from left to right.
  • Swap the ball with 44 written on it with the next ball to the right. Now, the balls have integers 1,2,3,4,51,2,3,4,5 written on them, from left to right.
  • Swap the ball with 55 written on it with the next ball to the left, since it is the rightmost ball. Now, the balls have integers 1,2,3,5,41,2,3,5,4 written on them, from left to right.
7 7
7
7
7
7
7
7
7
1 2 3 4 5 7 6
10 6
1
5
2
9
6
6
1 2 3 4 5 7 6 8 10 9