Problem: Mr. Haskins is working on tuning a database system. The database is a simple associative storage that contains key-value pairs. In this database, a key is a distinct identification (ID) number and a value is an object of any type.

In order to boost the performance, the database system has a cache mechanism. The cache can be accessed much faster than the normal storage, but the number of items it can hold at a time is limited. To implement caching, he selected least recently used (LRU) algorithm: when the cache is full and a new item (not in the cache) is being accessed, the cache discards the least recently accessed entry and adds the new item.

You are an assistant of Mr. Haskins. He regards you as a trusted programmer, so he gave you a task. He wants you to investigate the cache entries after a specific sequence of accesses.



Input

The first line of the input contains two integers N and M. N is the number of accessed IDs, and M is the size of the cache. These values satisfy the following condition: 1 ≤ N, M ≤ 100000.

The following N lines, each containing one ID, represent the sequence of the queries. An ID is a positive integer less than or equal to 109.

Output

Print IDs remaining in the cache after executing all queries. Each line should contain exactly one ID. These IDs should appear in the order of their last access time, from the latest to the earliest.

Example

Input




Output

Solution (in JAVA):

Solution:
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	// Scanner sc=new Scanner(System.in);
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int INF=1<<28;
	double EPS=1e-12;

	int n, m;
	int[] a;

	void run(){
		try{
			String[] ss=br.readLine().split(" ");
			n=Integer.parseInt(ss[0]);
			m=Integer.parseInt(ss[1]);
			a=new int[n];
			for(int i=0; i<n; i++){
				a[i]=Integer.parseInt(br.readLine());
			}
			solve();
		}catch(IOException e){}
	}

	void solve(){
		TreeSet<Integer> set=new TreeSet<Integer>();
		int count=0;
		for(int i=n-1; i>=0; i--){
			if(!set.contains(a[i])){
				println(a[i]+"");
				if(++count==m){
					break;
				}
			}
			set.add(a[i]);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}