J One of Each
题号:NC224721
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You are given a sequence of n integers  and an integer k

It is guaranteed that  , and every integer from 1 to k will appears in the list X at least once. 

Find the lexicographically smallest subsequence of X that contains each integer from 1 to k exactly once.

输入描述:

The first line of input contains two integers n and k (), where n is the size of the sequence, and the sequence consists only of integers from 1 to k.
Each of the next n lines contains a single integer . These are the values of the sequence in order. 
It is guaranteed that every value from 1 to k will appear at least once in the sequence X

输出描述:

Output a sequence of integers on a single line, separated by spaces. 
This is the lexicographically smallest subsequence of that contains every value from 1 to k.
示例1

输入

复制
6 3 
3 
2 
1 
3 
1 
3

输出

复制
2 1 3
示例2

输入

复制
10 5 
5 
4 
3 
2 
1 
4 
1 
1 
5 
5

输出

复制
3 2 1 4 5