Killjee and special Queue

0

0 votes
Easy
Problem

Killjee has 2 list of numbers, first one contains P integers and second one contains N integers. 

Killjee pushes all the numbers of first number into his special queue.

After pushing all number of 1st list killjee start pushing elements of 2nd list but queue can't hold more than P integers and all elements of 1st list are distinct, So

  • If number to be pushed is already present in queue killjee rights Present in a secret paper and moves this number to last of his special queue
  • If number to be pusher is not present in Killjee's special queue, he pops front element from his special queue and pushes the number to be pushed to the queue. After doing this killjee rights Removed X, where X is the number removed from special queue.

Killjee slept after doing the above process for whole list but his nautorius friend beer burnt that secret paper given the two list can you generate the whole secret paper again for killjee as, he is trying to find some job for himself.

INPUT

First line of input contains two space separated integers N and P.

Second line of input contains P space separated integers, elements of first list.

Third line contains N space separated integers, elements of second list.

OUTPUT

Print the contents of secret paper which killjee had prepared.

CONSTRAINTS

1N104

1P103

1 Numbers in list 109

Sample Input
3 2
1 2
2 3 2
Sample Output
Present
Removed 1
Present
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?