Course registration

Given a click log of student numbers and K seats, keep each student's last click, then print the first K distinct students in that order.

Easy3QueueHash mapSimulationInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

Every semester students register for courses through the university information system. The moment registration opens, a large number of students click at once and the server load grows, so the university runs a registration load management system with the following rules.

  1. After the registration button becomes active, a student who clicks it earlier enters the waiting list earlier.
  2. If a student who is already on the waiting list clicks the button again, that student is pushed to the back of the waiting list.
  3. A little later the button is deactivated, and registration completes automatically starting from the front of the waiting list. Once the seats are full, the rest of the waiting list is ignored and registration ends.

The table above shows six students registering for an algorithms course with three seats. When the button is deactivated, the earlier entries of any student who clicked more than once are deleted, so only each student's last click remains. The first three students of that cleaned list are then taken. The rightmost column of the table shows the result. Write a program that prints the students who succeeded in registering under these rules.

Input

Input is given on standard input and consists of a single test case. The first line contains the number of seats KK (1K100,0001 \le K \le 100{,}000) and the length LL (1L500,0001 \le L \le 500{,}000) of the waiting list that records the click order. Each of the next LL lines contains the student number of a student who clicked the button, in click order. A student number consists of 8 digits and may start with 0.

Output

Use standard output. After the rules are applied, print the student number of every student who succeeded in registering, one per line, in the order the registrations are processed. If fewer than KK distinct students clicked the button, print all of them.