P24977 [AtCoder] [ARC042A] Bulletin Board
普及
题目描述

Problem Description

There is a bulletin board with threads numbered from $ 1 $ to $ N $. When a thread receives a new post, it moves to the top. Before any posts, the threads are arranged in order from top to bottom, from $ 1 $ to $ N $. Given $ M $ posts in the order they were made, output the order of the threads after all posts have been made.

For example, if there are $ 3 $ threads on the bulletin board and posts are made in the order $ 2 $, $ 3 $, $ 1 $, the order will be as follows:

Thus, after all posts, the order of the threads will be $ 1 $, $ 3 $, $ 2 $.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ a_1 $ $ a_2 $ : $ a_M $

  • The first line contains two integers $N,\ M\ (1\ ≦\ N\ ≦\ 10^5,\ 1\ ≦\ M\ ≦\ 10^5)$ representing the number of threads and the number of posts, separated by a space.
  • The following $ M $ lines contain an integer $a_i\ (1\ ≦\ a_i\ ≦\ N)$ representing the thread that received the $ i $-th post.

Output Format

Output the thread numbers from top to bottom after all posts have been made, one per line.

Sample Input and Output

Sample Input #1

3 3
2
3
1

Sample Output #1

1
3
2

Sample Input #2

3 3
1
1
1

Sample Output #2

1
2
3

Sample Input #3

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

Sample Output #3

3
5
6
2
9
1
4
7
8
10

Notes/Hints

Partial Points

This problem has partial points.

  • If you solve the dataset where $1\ ≦\ N\ ≦\ 100,\ 1\ ≦\ M\ ≦\ 100$, you will be awarded $ 30 $ points.

Sample Explanation 1

After the first post, the threads are in the order $ 2 $, $ 1 $, $ 3 $. After the second post, they are in the order $ 3 $, $ 2 $, $ 1 $. After the third post, they are in the order $ 1 $, $ 3 $, $ 2 $.

Sample Explanation 2

Since only the thread originally at the top (thread $ 1 $) received posts, the order of the threads remains unchanged.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 2 3 1
样例输出
1 3 2