The only difference between easy and hard versions are constraints on $n$ and $k$.

You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $k$ most recent conversations with your friends. Initially, the screen is empty (i.e. the number of displayed conversations equals $0$).

Each conversation is between you and some of your friends. There is at most one conversation with any of your friends. So each conversation is uniquely defined by your friend.

You (suddenly!) have the ability to see the future. You know that during the day you will receive $n$ messages, the $i$-th message will be received from the friend with ID $id_i$ ($1 \le id_i \le 10^9$).

If you receive a message from $id_i$ in the conversation which is currently displayed on the smartphone then nothing happens: the conversations of the screen do not change and do not change their order, you read the message and continue waiting for new messages.

Otherwise (i.e. if there is no conversation with $id_i$ on the screen):  Firstly, if the number of conversations displayed on the screen is $k$, the last conversation (which has the position $k$) is removed from the screen.  Now the number of conversations on the screen is guaranteed to be less than $k$ and the conversation with the friend $id_i$ is not displayed on the screen.  The conversation with the friend $id_i$ appears on the first (the topmost) position on the screen and all the other displayed conversations are shifted one position down. 

Your task is to find the list of conversations (in the order they are displayed on the screen) after processing all $n$ messages.


-----Input-----

The first line of the input contains two integers $n$ and $k$ ($1 \le n, k \le 200)$ — the number of messages and the number of conversations your smartphone can show.

The second line of the input contains $n$ integers $id_1, id_2, \dots, id_n$ ($1 \le id_i \le 10^9$), where $id_i$ is the ID of the friend which sends you the $i$-th message.


-----Output-----

In the first line of the output print one integer $m$ ($1 \le m \le min(n, k)$) — the number of conversations shown after receiving all $n$ messages.

In the second line print $m$ integers $ids_1, ids_2, \dots, ids_m$, where $ids_i$ should be equal to the ID of the friend corresponding to the conversation displayed on the position $i$ after receiving all $n$ messages.


-----Examples-----
Input
7 2
1 2 3 2 1 3 2

Output
2
2 1 

Input
10 4
2 3 3 1 1 2 1 2 3 3

Output
3
1 3 2 



-----Note-----

In the first example the list of conversations will change in the following way (in order from the first to last message):  $[]$;  $[1]$;  $[2, 1]$;  $[3, 2]$;  $[3, 2]$;  $[1, 3]$;  $[1, 3]$;  $[2, 1]$. 

In the second example the list of conversations will change in the following way:  $[]$;  $[2]$;  $[3, 2]$;  $[3, 2]$;  $[1, 3, 2]$;  and then the list will not change till the end.

Difficulty: introductory

Starter code:

Solutions:
from collections import deque
n, k = map(int, input().split())
A = list(map(int, input().split()))
B = deque()
B.append(A[0])
for i in range(1, n):
    if A[i] not in B:
        if len(B) == k:
            B.popleft()
        B.append(A[i])
    else:
        pass
print(len(B))
print(*list(B)[::-1])

from collections import deque

n, k = list(map(int, input().split()))
ar = list(map(int, input().split()))
lol = deque([])
for elem in ar:
    if elem not in lol:
        if len(lol) == k:
            lol.pop()
        lol.appendleft(elem)
print(len(lol))
print(*lol)

from collections import deque
a, b = map(int, input().split())
li = list(map(int, input().split()))
s = set()
l = deque([])
le = 0
for i in li:
    if i in s:
        pass
    elif le < b:
        le += 1
        s.add(i)
        l.appendleft(i)
    else:
        s.remove(l.pop())
        s.add(i)
        l.appendleft(i)       
print(len(l))
print(*list(l))

import sys
input = sys.stdin.readline

n,k=list(map(int,input().split()))
A=list(map(int,input().split()))

SET=set()

from collections import deque

Q=deque()

for a in A:
    if a in SET:
        continue
    else:
        if len(Q)==k:
            x=Q.pop()
            SET.remove(x)
            Q.appendleft(a)
            SET.add(a)
        else:
            SET.add(a)
            Q.appendleft(a)

print(len(Q))
print(*Q)
            
            


from collections import deque
n, k = list(map(int, input().split()))
s = set()
d = deque()
for i in map(int, input().split()):
    if i in s:
        continue
    if len(d) == k:
        s.discard(d.pop())
    d.appendleft(i)
    s.add(i)
print(len(d))
print(*d)


n,k=map(int,input().split())
ide=input().split()
for i in range(n):
    ide[i]=int(ide[i])
a=[]
for i in range(n):
    if(ide[i] in a):
        continue
    else:
        if(len(a)<k):
            a.append(ide[i])
        else:
            a.pop(0)
            a.append(ide[i])
print(len(a))
for i in range(len(a)):
    print(a[len(a)-1-i],end=" ")
print()    

n, k = list(map(int, input().split()))

d = list(map(int, input().split()))

in_list = set()

con = []

for x in d:
	if x in in_list:
		continue
	if len(con) == k:
		top = con[0]
		in_list.remove(top)
		con.pop(0)

	con.append(x)
	in_list.add(x)

print(len(con))
print(*con[::-1])


from collections import deque

n, k = map(int ,input().split())
q = deque(maxlen=k)
c = list(map(int, input().split()))
for i in c:
    if i not in q:
        q.append(i)
    else:
        continue
print(len(q))
print(*list(q)[::-1])

n, k = tuple(map(int, input().split()))
arr = list(map(int, input().split()))

nowlist = []
nowset = set()

for i in arr:
    if i in nowset:
        continue
    if len(nowlist) == k:
        nowset.remove(nowlist.pop())
    nowlist = [i] + nowlist
    nowset.add(i)

print(len(nowlist))
print(*nowlist)


n,k=map(int,input().split())
l=[int(i) for i in input().split()]
#n msgs  i Th from idiur 
curr=[]
for i in l:
    if i in curr:
        pass 
    else: 
        if len(curr)==k:
            curr.pop()
            curr.insert(0,i)
        else:
            curr.insert(0,i)
print(len(curr))
print(*curr)

n, m = map(int, input().split())
data = list(map(int, input().split()))
array = []
c = 0
for i in data:
    if i not in array:
        c += 1
        if c > m:
            array = [i] + array[:-1]
        else:
            array = [i] + array
print(m if c >= m else c)
print(*array)

n, k = map(int, input().split())
ids = input().split()
queue = []
for i in ids:
    if len(queue) < k and i not in queue:
        queue.insert(0, i)
    elif len(queue) >= k and i not in queue:
        del queue[-1]
        queue.insert(0, i)
print(len(queue))
print(' '.join(queue))

n,k = map(int,input().split())
l = []
for i in map(int,input().split()):
    if i not in l:
        if len(l)==k:
            del l[-1]
        l.insert(0,i)
print(len(l))
print(*l)

from collections import deque
n,k=map(int,input().split())
d=deque()
s=set()
for i in map(int,input().split()):
  if i in s:continue
  d.appendleft(i);s.add(i)
  if len(d)>k:s.discard(d.pop())
print(len(d))
print(*d)

import sys

def main():
    def input():
        return sys.stdin.readline()[:-1]

    n, k = map(int,input().split())
    a = list(map(int,input().split()))
    l = []
    for e in a:
        if len(l) == k:
            if e not in l:
                l = [e] + l[:-1]
            else:
                pass
        else:
            if e not in l:
                l = [e] + l
            else:
                pass
    print(len(l))
    print(*l, sep = " ")
def __starting_point():
    main()

__starting_point()

n, k = map(int, input().strip().split())
ids = map(int, input().strip().split())
convs = []
for i in ids:
    if i in convs:
        continue
    elif len(convs) == k:
        convs.pop()
    convs.insert(0, i)
print(len(convs))
print(" ".join(map(str, convs)))

n,k = [int(i) for i in input().split()]

msg = [int(i) for i in input().split()]

fila = []
for i in msg:
    if i in fila:
        continue
    if len(fila) >= k:
        fila.pop()
    fila = [i] + fila
print(len(fila))
print(*fila)

        


n,k=list(map(int,input().split()))
l=list(map(int,input().split()))
l1=[]
for i in range(len(l)):
    if(l[i] not in l1):
        l1.insert(0,l[i])
    if(len(l1)>k):
        l1 = l1[:len(l1) - 1]
print(len(l1))
print(*l1)


def __starting_point():
    l = [int(i) for i in input().split(" ")]
    n = l[0]
    k = l[1]

    l = [int(i) for i in input().split(" ")]

    a = []

    for i in l:
        if i not in a:
            if len(a)>=k:
                a.pop()
            a.insert(0,i)

    print(len(a))

    for i in a:
        print(i, end=' ')





__starting_point()

from collections import defaultdict as df
import heapq
import bisect 
import math
from itertools import combinations,permutations
from collections import deque

n,k=list(map(int,input().split()))
a=list(map(int,input().rstrip().split()))
ans=[]
for i in a:
    if i in ans:
        pass
    else:
        if len(ans)>=k:
            ans.pop()
            ans.insert(0,i)
        else:
            ans.insert(0,i)
print(len(ans))
print(*ans)

import math
inp = lambda cast=int: [cast(x) for x in input().split()]
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)

n, k = inp()
A = inp()
B = []
for a in A:
    if a in B:
        continue
    B = [a] + B
    if len(B) > k:
        B.pop()
print(len(B))
for b in B:
    print(b, end=' ')


n, k = (int(x) for x in input().split())

msg = [int(x) for x in input().split()]

stk = []

for m in msg:
	if m in stk:
		continue

	stk.insert(0, m)
	while len(stk) > k:
		stk.pop()

print(len(stk))
for i in stk:
	print(i, end=" ")
print()

import heapq
n,k=map(int,input().split())
a=[int(o) for o in input().split()]
h=[]
s=set()
j=0
for i in range(n):
    if a[i] not in s:
        heapq.heappush(h,[i,a[i]])
        j+=1
        s.add(a[i])
        if j>k:
            j-=1
            lol=heapq.heappop(h)
            s.remove(lol[1])
st=[]
while h:
    st.append(heapq.heappop(h)[1])
st=st[::-1]
print(len(st))
print(*st)