Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with this friend before, then a new chat is simply inserted to the top of the list.

Assuming that the chat list is initially empty, given the sequence of Polycaprus' messages make a list of chats after all of his messages are processed. Assume that no friend wrote any message to Polycarpus.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 200 000) — the number of Polycarpus' messages. Next n lines enlist the message recipients in the order in which the messages were sent. The name of each participant is a non-empty sequence of lowercase English letters of length at most 10.


-----Output-----

Print all the recipients to who Polycarp talked to in the order of chats with them, from top to bottom.


-----Examples-----
Input
4
alex
ivan
roman
ivan

Output
ivan
roman
alex

Input
8
alina
maria
ekaterina
darya
darya
ekaterina
maria
alina

Output
alina
maria
ekaterina
darya



-----Note-----

In the first test case Polycarpus first writes to friend by name "alex", and the list looks as follows:   alex 

Then Polycarpus writes to friend by name "ivan" and the list looks as follows:  ivan  alex 

Polycarpus writes the third message to friend by name "roman" and the list looks as follows:  roman  ivan  alex 

Polycarpus writes the fourth message to friend by name "ivan", to who he has already sent a message, so the list of chats changes as follows:  ivan  roman  alex

Difficulty: EASY
Tags: Sorting

Data structures

Constructive algorithms
Skill types: Sorting

Data structures

Starter code:

Solutions:
def print_in_order(stack):
	names_appeared = set()
	while stack:
		name = stack.pop()
		if not name in names_appeared:
			print(name)
			names_appeared.add(name)
n = int(input())
stack = []
for _ in range(n):
	stack.append(input())
print_in_order(stack)


from collections import OrderedDict
ordered = {}
sms_numbers = int(input())
for i in range(0, sms_numbers):
	ordered[input()] = sms_numbers - i
OrderedDict(sorted(ordered.items(), key=lambda t: t[1]))
print('\n'.join((item for item in OrderedDict(sorted(ordered.items(), key=lambda t: t[1])).keys())))


n = int(input())
arr = {}
for i in range(n):
	s = input()
	arr[s] = i
d = list(arr.items())
from operator import itemgetter
d.sort(key=itemgetter(1), reverse=True)
for i in range(len(d)):
	print(d[i][0])


n = int(input())
chats = [input() for s in range(n)]
unique = set()
chats = reversed(chats)
for elem in chats:
	if elem not in unique:
		unique.add(elem)
		print(elem)


d = {}
for i in range(int(input())):
	s = input()
	d[s] = i
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
for i in d:
	print(i[0])


import math
n = int(input())
names = {}
for i in range(0, n):
	x = input()
	names[x] = i
names = sorted(names.items(), key=lambda x: x[1])
ans = []
for key in names:
	ans.append(key[0])
for i in range(len(ans) - 1, -1, -1):
	print(ans[i])


counter = int(input())
names = {}
for i in range(counter):
	line = input()
	names[line] = i

def main(names, counter):
	names = list(names.items())
	names.sort(key=lambda x: x[1], reverse=True)
	lines = [print(line[0]) for line in names]
main(names, counter)


n = int(input())
l = []
for _ in range(n):
	l.append(input())
answer = []
s = set()
for i in range(n - 1, -1, -1):
	if l[i] not in s:
		s.add(l[i])
		answer.append(l[i])
for _ in answer:
	print(_)


n = int(input())
a = []
for i in range(n):
	a.append(input())
a.reverse()
delSet = set()
for s in a:
	if s in delSet:
		continue
	delSet.add(s)
	print(s)


n = int(input())
arr = []
for i in range(n):
	line = input()
	arr.append(line)
res = []
d = {}
for i in arr[::-1]:
	if i not in d:
		res.append(i)
		d[i] = True
print('\n'.join(res))


n = int(input())
l = [input() for i in range(n)]
d = dict()
for i in range(n - 1, -1, -1):
	if l[i] not in d:
		d[l[i]] = 1
		print(l[i])


import sys

def solve():
	n = int(input())
	S = set()
	chat_list = []
	history = sys.stdin.read().split()
	for name in reversed(history):
		if not name in S:
			chat_list.append(name)
			S.add(name)
	for name in chat_list:
		sys.stdout.write(name + '\n')
solve()


n = int(input())
A = [0] * n
for i in range(n):
	A[i] = input()
mass = set()
per = 0
for i in range(n - 1, -1, -1):
	mass.add(A[i])
	t = len(mass)
	if t > per:
		per = t
		print(A[i])


n = int(input())
from time import time
k = time()
names = {}
res = []
for i in range(n):
	s = input()
	if s in names:
		res[names[s]] = False
	names[s] = i
	res.append(s)
for i in range(n - 1, -1, -1):
	if res[i] != False:
		print(res[i])


from collections import OrderedDict
totalMessages = int(input())
authors = list([(input(), True) for message in range(totalMessages)])
authors = authors[::-1]
for author in OrderedDict(authors).keys():
	print(author)


n = int(input())
m = [input() for i in range(n)][::-1]
k = {}
for i in m:
	if i in k:
		continue
	else:
		k[i] = -1
		print(i)


from operator import itemgetter
msgs = {}
for i in range(int(input())):
	msgs[input()] = i
for (k, v) in sorted(msgs.items(), key=itemgetter(1))[::-1]:
	print(k)


__author__ = 'Alexandret'
chats_amount = int(input())
chats_last_message = dict()
for i in range(chats_amount):
	uid = input()
	chats_last_message[uid] = i
l = lambda x: x[1]
tmp = sorted(chats_last_message.items(), key=l, reverse=True)
for i in tmp:
	print(i[0])


import operator
n = int(input())
d = {}
for i in range(n):
	a = str(input())
	d[a] = i + 1
m = sorted(d.items(), key=operator.itemgetter(1), reverse=True)
for i in m:
	print(i[0])


n = int(input())
chat_list = []
names = set()
for i in range(n):
	name = input()
	if name not in names:
		names.add(name)
	chat_list.append(name)
x = len(names)
for i in chat_list[::-1]:
	if i in names:
		print(i)
		names.remove(i)
		x -= 1
		if x == 0:
			break


def unique(lst):
	seen = set()
	result = []
	for x in lst:
		if x in seen:
			continue
		seen.add(x)
		result.append(x)
	return result
a = int(input())
c = []
for i in range(a):
	c += [input()]
print(*unique(reversed(c)), sep='\n')


n = int(input())
ST = []
SET = set()
for i in range(n):
	s = input()
	ST.append(s)
	SET.add(s)
i = n
while i > 0:
	p = ST.pop()
	if p in SET:
		SET.remove(p)
		print(p)
	i = i - 1


import operator
n = int(input())
friends = {}
for i in range(n):
	word = input()
	friends[word] = i
sortedfriends = {k: v for (k, v) in sorted(friends.items(), key=lambda item: item[1])}
res = list(sortedfriends.keys())
res.reverse()
for i in res:
	print(i)


n = int(input())
friend_list = dict()
for i in range(n):
	friend_list[input()] = i
friends = list(friend_list.keys())
friends.sort(reverse=True, key=lambda x: friend_list[x])
for friend in friends:
	print(friend)


n = int(input())
arr = [input() for _ in range(n)][::-1]
st = set()
for i in arr:
	if not i in st:
		print(i)
		st.add(i)


def main():
	n = int(input())
	a = [input() for i in range(n)]
	s = set()
	ans = []
	for i in a[::-1]:
		if i not in s:
			ans.append(i)
			s.add(i)
	print(*ans, sep='\n')
main()


s = {}
for j in [input() for i in range(int(input()))][::-1]:
	if j not in s:
		print(j)
		s[j] = 1


n = int(input())
last_pos = 0
chatlist = {}
for i in range(n):
	name = input()
	chatlist[name] = last_pos
	last_pos -= 1
name_pos_pairs = []
for name in chatlist:
	name_pos_pairs.append((name, chatlist[name]))
name_pos_pairs.sort(key=lambda x: x[1])
for pair in name_pos_pairs:
	print(pair[0])


n = int(input())
chat = {}
for i in range(n):
	t = input()
	chat[t] = (i, t)
for tup in sorted(chat.values(), reverse=True):
	print(tup[1])


from collections import OrderedDict as D
d = D()
for n in range(int(input())):
	x = input()
	d[x] = d.pop(x, None)
print('\n'.join(list(d.keys())[::-1]))


n = int(input())
inp = []
a = []
s = set()
for i in range(0, n):
	b = input()
	inp.append(b)
inp = inp[::-1]
for i in inp:
	if i not in s:
		a.append(i)
		s |= set([i])
for i in a:
	print(i)


n = int(input())
l = []
for i in range(n):
	l.append(input())
l = list(dict.fromkeys(reversed(l)))
for i in l:
	print(i)


num = input()
printed = {}
names = []
for i in range(int(num)):
	names.append(input())
for name in reversed(names):
	if name not in printed:
		print(name)
		printed[name] = True


n = int(input())
has = {}

def comp(e1):
	return e1[1]
for i in range(n):
	s = input()
	has[s] = i
ar = []
for (k, v) in has.items():
	ar.append([k, v])
ar.sort(key=comp, reverse=True)
for x in ar:
	print(x[0])


n = int(input())
u = {}
for x in [input() for _ in range(n)][::-1]:
	if x not in u:
		u[x] = 1
		print(x)


import sys
input = sys.stdin.readline
print = sys.stdout.write
n = int(input())
ar = [input() for x in range(n)][::-1]
s = set()
for x in ar:
	if x not in s:
		print(x)
	s.add(x)


def main():
	n = int(input())
	our = [input() for i in range(n)]
	made = set()
	while our:
		c = our[-1]
		if c not in made:
			made.add(c)
			print(c)
		our.pop()
main()


num = input()
printed = set()
names = []
for i in range(int(num)):
	names.append(input())
for i in reversed(names):
	if i not in printed:
		print(i)
		printed.add(i)


import sys
n = int(input())
a = [input() for i in range(n)]
mp = {}
for i in range(n - 1, -1, -1):
	try:
		mp[a[i]] += 1
	except:
		print(a[i])
		mp[a[i]] = 1


p = []
dic = {}
n = int(input())
for _ in range(n):
	s = input()
	p.append(s)
	dic[s] = 1
for i in range(len(p) - 1, -1, -1):
	if dic[p[i]] == 0:
		continue
	else:
		dic[p[i]] = 0
		print(p[i])


n = int(input())
list = []
appear = {}
for i in range(n):
	list.append(input())
l = len(list)
for i in range(l):
	name = list[l - 1 - i]
	if appear.get(name, 0) == 0:
		print(name)
		appear[name] = 1


n = int(input())
l = []
d = {}
for i in range(n):
	s = input()
	l.append(s)
l.reverse()
for x in l:
	if d.get(x, -1) == -1:
		print(x)
		d[x] = 1


n = int(input())
d = {}
for i in range(n):
	d[input()] = i
a = [x for x in d.items()]
for v in sorted(a, key=lambda v: v[1], reverse=True):
	print(v[0])


z = [input() for i in range(int(input()))]
z.reverse()
lst = set(z)
for i in z:
	if i in lst:
		print(i)
		lst.remove(i)


def solve(chat_history):
	chat_list = []
	used = dict()
	for chat in reversed(chat_history):
		if chat in used:
			continue
		chat_list.append(chat)
		used[chat] = True
	return chat_list

def main():
	n = int(input())
	chat_history = [None] * n
	for i in range(n):
		chat_history[i] = input()
	chat_list = solve(chat_history)
	for chat in chat_list:
		print(chat)
main()


n = int(input())
names = {}
for i in range(n):
	name = input()
	names[name] = i
for (name, key) in sorted(zip(names.values(), names.keys()), reverse=True):
	print(key)


import operator
a = dict()
for i in range(int(input())):
	b = input()
	try:
		a[b] = i
	except KeyError:
		a[b] = 0
c = sorted(a.items(), key=operator.itemgetter(1), reverse=True)
d = []
for i in range(len(c)):
	d.append(c[i][0])
print(*d, sep='\n')


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	a = [''] * n
	mp = {}
	cur = n - 1
	for i in range(n):
		s = input()
		mp[s] = cur
		cur -= 1
	for (name, ind) in mp.items():
		a[ind] = name
	for v in a:
		if v:
			print(v)


n = int(input())
di = {}
for i in range(n):
	di[input()] = n + 1 - i
print('\n'.join(sorted(di, key=lambda x: di[x])))


nexts = {}
prevs = {}
n = int(input())
cur = input()
prevs[cur] = -1
nexts[cur] = -1
for i in range(1, n):
	x = input()
	if x in list(nexts.keys()):
		if cur != x:
			nexts[prevs[x]] = nexts[x]
			prevs[nexts[x]] = prevs[x]
			prevs[x] = cur
			nexts[cur] = x
			nexts[x] = -1
			cur = x
	else:
		nexts[cur] = x
		prevs[x] = cur
		cur = x
		nexts[x] = -1
while prevs[cur] != -1:
	print(cur)
	cur = prevs[cur]
print(cur)


name = set()
ans = list()
n = int(input())
all = [input() for i in range(n)]
need = all[::-1]
for i in need:
	if i not in name:
		name.add(i)
		ans.append(i)
for i in ans:
	print(i)


n = int(input())
seq = {}
for a in range(n):
	seq[input()] = a
seq = sorted(seq.items(), key=lambda d: d[1], reverse=True)
for pair in seq:
	print(pair[0])


n = int(input())
k = list()
m = set()
for i in range(n):
	a = input()
	k.append(a)
	m.add(a)
for i in range(n - 1, -1, -1):
	if k[i] in m:
		print(k[i], end='\n')
		m.discard(k[i])


n = int(input())
ranks = dict()
for k in range(n):
	ranks[input()] = k
for name in reversed(sorted(ranks, key=lambda key: ranks[key])):
	print(name)


n = int(input())
s = set()
a = []
for x in [input() for i in range(n)][::-1]:
	if not x in s:
		a += [x]
		s |= {x}
print('\n'.join(a))


n = int(input())
a = [input() for i in range(n)]
s = set()
for i in a[::-1]:
	if not i in s:
		print(i)
	s.add(i)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mod = 1000000007
from math import log, sqrt, factorial, cos, tan, sin, radians, ceil, floor
import bisect
from decimal import *
getcontext().prec = 25
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def main():
	n = ii()
	d = {}
	l = []
	c = 0
	for i in range(n):
		s = si()
		l.append(s)
		if s not in d:
			d[s] = 1
			c += 1
	ans = []
	for i in range(n - 1, -1, -1):
		if d[l[i]]:
			print(l[i])
			d[l[i]] = 0
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
from collections import OrderedDict
Lines = []
for Line in sys.stdin:
	Lines.append(Line.rstrip('\n'))
n = int(Lines[0])
del Lines[0]
p = list(OrderedDict.fromkeys(Lines[::-1]))
for i in range(len(p)):
	print(p[i])


n = int(input())
d = {}
for x in [input() for i in range(n)][::-1]:
	if not x in d:
		d[x] = 1
		print(x)


n = int(input())
order = []
messages = []
d = set()
for i in range(n):
	name = input()
	messages.append(name)
for i in range(n - 1, -1, -1):
	if messages[i] not in d:
		order.append(messages[i])
		d.add(messages[i])
for i in order:
	print(i)


from collections import OrderedDict
n = int(input())
names = OrderedDict()
for i in range(n):
	x = input()
	if x in names:
		names.move_to_end(x)
	else:
		names[x] = 0
for i in reversed(list(names)):
	print(i)


__author__ = 'Utena'
import operator
chat = dict()
top = 0
n = int(input())
for i in range(n):
	s = input()
	chat[s] = top + 1
	top = top + 1
chat = sorted(chat.items(), key=lambda x: x[1], reverse=1)
for i in range(len(chat)):
	print(chat[i][0])


class Node:

	def __init__(self, val):
		self.val = val
		self.next = None
		self.prev = None

class DLL:

	def __init__(self):
		self.head = None
		self.tail = None
		self.d = {}

	def insert(self, name):
		if name in self.d:
			self.removeInsert(name)
			return
		node = Node(name)
		if self.head == None:
			self.head = node
			self.tail = node
		else:
			node.next = self.head
			self.head.prev = node
			self.head = node
		self.d[name] = node

	def removeInsert(self, name):
		node = self.d[name]
		if node != self.head:
			node.prev.next = node.next
			if node == self.tail:
				self.tail = node.prev
			else:
				node.next.prev = node.prev
			del node
			newnode = Node(name)
			newnode.next = self.head
			self.head.prev = newnode
			self.head = newnode
			self.d[name] = newnode
n = int(input())
dll = DLL()
for i in range(n):
	dll.insert(input())
p = dll.head
while p != None:
	print(p.val)
	p = p.next


(d, l) = ({}, [input() for i in range(int(input()))])
for i in l:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
for i in l[::-1]:
	if d[i] > 0:
		print(i)
		d[i] = 0


(a, d) = ([input() for i in range(int(input()))], {})
for i in reversed(a):
	if i not in d.keys():
		print(i)
	d[i] = 1


n = int(input())
lis = []
for i in range(0, n):
	lis.append(input())
lis.reverse()
dic = {}
j = 1
for i in lis:
	if i not in dic:
		dic[i] = j
		j += 1
lis = list(dic.items())
lis.sort(key=lambda kv: (kv[1], kv[0]))
for i in lis:
	print(i[0])


from collections import defaultdict
n = int(input())
names = list()
names_map = defaultdict(lambda : 0)
result = list()
for _ in range(n):
	names.append(input())
for i in range(n - 1, -1, -1):
	if names_map[names[i]] == 0:
		result.append(names[i])
	names_map[names[i]] = 1
print('\n'.join(result))


n = int(input())
deja_rentre = dict()
for i in range(n):
	name = input()
	deja_rentre[name] = n - i
for (name, _) in sorted(list(deja_rentre.items()), key=lambda c: c[1]):
	print(name)


n = int(input())
l = [input() for i in range(n)]
m = {}
for i in range(n - 1, -1, -1):
	if not l[i] in m:
		m[l[i]] = True
		print(l[i])


def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)
n = it()
dict = {}
L = [ip() for _ in range(n)][::-1]
for x in L:
	if not x in dict:
		dict[x] = 1
		print(x)


n = int(input())
messages = [input() for x in range(n)]
users = {x: 0 for x in messages}
counter = 0
for x in messages:
	users[x] = counter
	counter += 1
for x in sorted(users.items(), key=lambda x: x[1], reverse=True):
	print(x[0])


users = [input() for _ in range(int(input()))]
duplicated = {}
for user in users[::-1]:
	if user not in duplicated:
		print(user)
		duplicated[user] = 1


def solve(messages):
	visited = set()
	order = []
	for i in range(len(messages) - 1, -1, -1):
		if messages[i] not in visited:
			order.append(messages[i])
			visited.add(messages[i])
	return order
messages_count = int(input())
messages = []
for i in range(messages_count):
	messages.append(input())
order = solve(messages)
print('\n'.join(order))


d = dict()
n = int(input())
l = [None] * n
for i in range(n):
	m = input()
	d[m] = False
	l[i] = m
for i in l[::-1]:
	if not d[i]:
		print(i)
		d[i] = True


n = int(input())
names = {}
for i in range(n):
	s = str(input())
	names[s] = i
names = sorted(names, key=lambda x: names[x], reverse=True)
for i in range(len(names)):
	print(names[i])


t = int(input())
q = list()
for i in range(t):
	n = input()
	q.append(n)
s = set(q)
while len(s) > 0:
	for j in q[::-1]:
		if j in s:
			print(j)
			s.remove(j)
	else:
		break


check = set()
answer = []
number = []
n = int(input())
count = 0
for i in range(0, n, 1):
	s = str(input())
	number.append(s)
for i in range(n - 1, -1, -1):
	check.add(number[i])
	a = len(check)
	if a > count:
		count += 1
		answer.append(number[i])
pp = len(answer)
for i in range(0, pp, 1):
	print(answer[i])


n = int(input())
chat = {}
for i in range(n):
	chat[input()] = i
c = {}
for i in chat.keys():
	c[chat[i]] = i
m = []
for i in sorted(list(c.keys()), reverse=True):
	m.append(c[i])
print(*m, sep='\n')


n = int(input())
friends = []
chat = set()
final = []
for i in range(n):
	friends.append(input())
for i in range(len(friends) - 1, -1, -1):
	if friends[i] not in chat:
		final.append(friends[i])
		chat.add(friends[i])
for i in range(len(final)):
	print(final[i])


dct = dict()
for i in range(int(input())):
	dct[input()] = i
lst = []
for key in dct:
	lst.append([dct[key], key])
lst.sort(reverse=True)
for i in lst:
	print(i[1])


n = int(input())
D = dict()
A = []
for i in range(n):
	s = input()
	if s not in D:
		D[s] = i
		A.append(s)
	else:
		A.append(0)
		(A[D[s]], A[-1]) = (A[-1], A[D[s]])
		D[s] = i
for i in range(len(A) - 1, -1, -1):
	if A[i] != 0:
		print(A[i])


n = int(input())
m = {}
for i in range(n):
	s = input()
	m[s] = (-i, s)
m = [t[1] for t in sorted(m.values())]
print('\n'.join(m))


n = int(input())
strings = []
s = set()
for i in range(n):
	strings.append(input())
for f in strings[::-1]:
	if f not in s:
		s.add(f)
		print(f)


n = int(input())
d = dict()
for i in range(0, n):
	s = input()
	d[s] = i
l = sorted(d.items(), key=lambda x: x[1], reverse=True)
for k in l:
	print(k[0])


n = int(input())
l = [input() for i in range(n)]
l.reverse()
b = {}
for i in l:
	if i not in b:
		b[i] = 1
		print(i)


t = []
f = {}
n = int(input())
for i in range(n):
	a = input()
	t.append(a)
for j in range(n - 1, -1, -1):
	if t[j] not in f:
		print(t[j])
		f[t[j]] = 1


from collections import defaultdict
from sys import stdin
res = []
used = set()
input = stdin.readlines()
input.pop(0)
for name in reversed(input):
	if name not in used:
		print(name, end='')
		used.add(name)


from collections import defaultdict
d = defaultdict(lambda : 0)
K = int(input())
n = ''
for k in range(K):
	d[input()] = k
di = [x for x in d.items()]
for x in sorted(di, key=lambda x: x[1], reverse=True):
	print(x[0])


n = int(input())
s = [input() for i in range(n)]
chat = {}
for x in s[::-1]:
	if x not in chat:
		chat[x] = 1
		print(x)


def solution(l):
	unique_persons = set()
	while len(l) > 0:
		if l[-1] in unique_persons:
			l.pop()
		else:
			print(l[-1])
			unique_persons.add(l[-1])
			l.pop()
n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
solution(l)


import sys
import collections
_ = sys.stdin.readline()
names = collections.OrderedDict()
while True:
	name = sys.stdin.readline()
	name = name.strip()
	if not name:
		break
	if name not in names:
		names[name] = None
	names.move_to_end(name)
sys.stdout.write('\n'.join(reversed(names)))


n = int(input())
recipients = [input() for _ in range(0, n)]
alreadydone = set()
for i in range(0, n):
	c = recipients[n - i - 1]
	if c not in alreadydone:
		print(c)
		alreadydone.add(c)


n = int(input())
doth = {}
for i in range(n):
	doth.update({input(): i})
dcont = {}.fromkeys(range(n))
for t2 in doth.items():
	dcont[t2[1]] = t2[0]
for i in range(n - 1, -1, -1):
	if dcont[i] != None:
		print(dcont[i])


n = int(input())
chat = []
position = {}
for i in range(n):
	s = str(input())
	try:
		chat[position[s]] = 'N'
	except:
		pass
	chat.append(s)
	position[s] = i
for j in range(n - 1, -1, -1):
	if chat[j] != 'N':
		print(chat[j])


from collections import defaultdict as dq
n = int(input())
z = []
d = dq(int)
for _ in range(n):
	z.append(input())
for x in range(n - 1, -1, -1):
	if d[z[x]] == 0:
		print(z[x])
		d[z[x]] = 1


from sys import stdin
input()
d = {s: i for (i, s) in enumerate(stdin.read().splitlines())}
print('\n'.join(sorted(d.keys(), key=d.get, reverse=True)))


from collections import Counter
T = int(input())
name = []
for t in range(T):
	n = input()
	name.append(n)
name.reverse()
ctr = list(Counter(name).keys())
print('\n'.join(ctr))


n = int(input())
data = [input() for i in range(n)]
res = set()
for v in reversed(data):
	if not v in res:
		print(v)
		res.add(v)


(I, d) = (input, {})
for i in [I() for i in range(int(I()))][::-1]:
	if i not in d:
		print(i)
	d[i] = 1


n = int(input())
rank = {}
for i in range(n):
	rank[input()] = i
print('\n'.join(sorted(rank, key=lambda x: rank[x], reverse=True)))


a = set()
nxt = {}
pre = {}
top = ''
for i in range(int(input())):
	s = input()
	if s not in a:
		nxt[s] = top
		pre[top] = s
		top = s
		a.add(s)
	elif s != top:
		(pre[nxt[s]], nxt[pre[s]]) = (pre[s], nxt[s])
		nxt[s] = top
		pre[top] = s
		top = s
ans = []
while top != '':
	ans.append(top)
	top = nxt[top]
print('\n'.join(ans))


from collections import deque
n = int(input())
fritem = list()
friend = deque(fritem)
out = dict()
for i in range(n):
	name = input()
	out[name] = 1
	friend.appendleft(name)
for i in range(n):
	tem = friend.popleft()
	if out[tem] != 0:
		print(tem)
	out[tem] = 0


from sys import stdin
all_in = stdin.readlines()
n = int(all_in[0])
adr = list(map(lambda x: x.rstrip('\n'), all_in[1:]))
was = set()
ans = list()
for el in adr[::-1]:
	if el not in was:
		ans.append(el)
		was.add(el)
print('\n'.join(ans))


n = int(input())
ls = []
mass = dict()
for i in range(n):
	massage = input()
	ls.append(massage)
for i in range(n - 1, -1, -1):
	try:
		if not mass[ls[i]]:
			print(ls[i])
	except:
		a = ls[i]
		mass[str(a)] = 1
		print(ls[i])


n = int(input())
a = []
d = {}
l = 0
k = n
while l < n:
	a.append(input())
	d[a[l]] = False
	l += 1
k = k - 1
while k >= 0:
	if not d[a[k]]:
		print(a[k])
		d[a[k]] = True
	k -= 1


import datetime
n = int(input())
arr = []
for i in range(n):
	arr.append(input())
new = set()
arr.reverse()
for i in arr:
	if i not in new:
		print(i)
		new.add(i)


n = int(input())
name = {}
for i in range(n):
	s = input()
	name[s] = i
a = list(name)
a.sort(key=lambda x: -name[x])
for i in range(len(a)):
	print(a[i])


n = int(input())
d = {}
for i in range(n):
	d[input()] = i
answer = []
k = list(d.keys())
for i in range(len(k)):
	answer += [(d[k[i]], k[i])]
answer.sort(reverse=True)
for i in range(len(answer)):
	print(answer[i][1])


n = int(input())
wee = {}
for i in range(n):
	temp = input()
	wee[temp] = i
result = sorted(wee.items(), key=lambda t: t[1], reverse=True)
for i in result:
	print(i[0])


n = int(input())
a = []
for i in range(n):
	a.append(input().rstrip('\n'))
done = set([])
for i in range(n - 1, -1, -1):
	if a[i] not in done:
		print(a[i])
		done.add(a[i])


n = int(input())
chat = {}
for i in range(n):
	chat[input()] = i
c = {}
for i in chat.keys():
	c[chat[i]] = i
t = list(c.keys())
t.sort(reverse=True)
for i in t:
	print(c[i])


from sys import stdin

def input():
	return stdin.readline()
a = set()
nxt = {}
pre = {}
top = ''
for i in range(int(input())):
	s = input()
	if s not in a:
		nxt[s] = top
		pre[top] = s
		top = s
		a.add(s)
	elif s != top:
		(pre[nxt[s]], nxt[pre[s]]) = (pre[s], nxt[s])
		nxt[s] = top
		pre[top] = s
		top = s
ans = []
while top != '':
	ans.append(top)
	top = nxt[top]
print('\n'.join(ans))


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def solve():
	n = ii()
	a = []
	for i in range(n):
		a.append(si())
	m = {}
	a.reverse()
	for i in a:
		if i in m:
			continue
		print(i)
		m[i] = 1
solve()


n = int(input())
a = [input() for i in range(n)]
was = set()
for name in a[::-1]:
	if name not in was:
		was.add(name)
		print(name)


d = {}
st = []
n = int(input())
for i in range(n):
	st.append(input())
for i in range(n - 1, -1, -1):
	d[st[i]] = d.get(st[i], 0) + 1
	if d[st[i]] == 1:
		print(st[i])


n = int(input())
s = [''] * (n + 100)
for i in range(n):
	s[i] = input()
used = set()
for j in range(n - 1, -1, -1):
	if not s[j] in used:
		used.add(s[j])
		print(s[j])


import sys
n = int(input())
a = []
for i in range(0, n):
	a.append(input())
se = {''}
i = n - 1
while i >= 0:
	size1 = len(se)
	se.add(a[i])
	if size1 != len(se):
		print(a[i])
	i -= 1


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
q = {1}
for i in range(n - 1, -1, -1):
	if arr[i] not in q:
		q |= {arr[i]}
		print(arr[i])


n = int(input())
l = []
while n:
	l.append(input())
	n -= 1
a = set()
for i in reversed(l):
	if not i in a:
		a.add(i)
		print(i)


l = list()
s = set()
n = int(input())
for i in range(n):
	l.append(input())
for i in range(n):
	c = l[n - i - 1]
	if c not in s:
		print(c)
		s.add(c)


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
l = l[::-1]
d = set()
for i in l:
	if i not in d:
		d.add(i)
		print(i)


n = int(input())
chats = {}
for i in range(n):
	name = input()
	chats[name] = i
chats = sorted(chats.items(), key=lambda d: d[1], reverse=True)
for x in chats:
	print(x[0])


def val(x):
	return x[1]
n = int(input())
chatQ = {}
c = 0
for i in range(1, n + 1):
	name = str(input())
	if name not in chatQ:
		chatQ[name] = i
	else:
		chatQ[name] = c
	c = chatQ.get(name) + 1
x = list(chatQ.keys())
y = list(chatQ.values())
z = []
for i in range(len(x)):
	z.append([x[i], y[i]])
z.sort(key=val, reverse=True)
for i in z:
	print(i[0])


n = int(input())
a = [input() for i in range(n)]
sa = set(a)
ts = set()
res = []
for name in reversed(a):
	if len(sa) == len(ts):
		break
	if not name in ts:
		res.append(name)
		ts.add(name)
print('\n'.join(res))


n = input('')
n = int(n)
d = {}
for i in range(n):
	name = input('')
	d[name] = i
l = list(d.items())
from operator import itemgetter
l.sort(key=itemgetter(1), reverse=True)
for i in range(len(l)):
	print(l[i][0])


data = int(input())
dict = {}
for i in range(data):
	line = input()
	dict[i] = line
nonre = {}
ans = []
for i in range(len(dict))[::-1]:
	if dict[i] not in nonre:
		nonre[dict[i]] = 1
		ans.append(dict[i])
		print(dict[i])


n = int(input())
a = [input() for _ in range(n)]
s = set()
for i in reversed(a):
	if i not in s:
		s.add(i)
		print(i)


n = int(input())
d = dict()
for i in range(n):
	s = input()
	b = (n - i) % 200
	a = (n - i) // 200
	d[s] = a * 'È' + chr(b)
d1 = sorted(d.items(), key=lambda d: d[1])
l = len(d1)
for i in range(l):
	print(d1[i][0])


from sys import stdin
input()
arr = stdin.read().splitlines()
st = set()
for i in arr[::-1]:
	if not i in st:
		print(i)
		st.add(i)


def main():
	mylist = []
	n = int(input())
	for i in range(n):
		name = input()
		mylist.append(name)
	d = {}
	for i in mylist[::-1]:
		if not d.get(i):
			print(i)
			d[i] = 1
main()


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	n = I()
	a = []
	for i in range(n):
		a.append(input().strip())
	s = set([])
	i = 1
	while i <= n:
		if a[-i] not in s:
			print(a[-i])
			s.add(a[-i])
		i += 1
for _ in range(1):
	case()


ls = []
for _ in range(int(input())):
	s = input()
	ls.append(s)
s = {}
for i in range(len(ls) - 1, -1, -1):
	if ls[i] not in s:
		print(ls[i])
	s[ls[i]] = 1


from sys import stdin, stdout
num_mensagens = int(stdin.readline().strip())
nomes = []
for idx in range(0, num_mensagens):
	nomes.append(stdin.readline().strip())
nomes.reverse()
nomes = list(dict.fromkeys(nomes))
for nome in nomes:
	stdout.writelines(nome + '\n')


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
arr = arr[::-1]
string = set()
for a in arr:
	if a not in string:
		string.add(a)
		print(a)


import collections
dp = {}
for i in range(int(input())):
	dp[input()] = i
x = sorted(dp.items(), key=lambda x: x[1], reverse=True)
for (i, a) in x:
	print(i)


(n, l) = (int(input()), [])
for i in range(n):
	l.append(input())
(q, l) = ({}, l[::-1])
for i in l:
	q[i] = 0
print(*q, sep='\n')


n = int(input())
seen = {}
data = []
for i in range(n):
	st = input().strip()
	data.append(st)
while data:
	st = data.pop()
	if st not in seen:
		seen[st] = True
		print(st)


n = int(input())
d = dict()
for i in range(n):
	name = input()
	d[name] = i
a = [(name, d[name]) for name in d]
a = sorted(a, key=lambda x: x[1], reverse=True)
for p in a:
	print(p[0])


from sys import stdin, stdout
import bisect as bs
from collections import defaultdict
for _ in range(1):
	n = int(stdin.readline())
	p = 1
	ans = float('inf')
	a = [''] * n
	mp = {}
	cur = n - 1
	for i in range(n):
		s = input()
		mp[s] = cur
		cur -= 1
	for (name, ind) in mp.items():
		a[ind] = name
	for v in a:
		if v:
			print(v)


import sys
order = []
appear = {}
n = int(input())
for i in range(n):
	str_ = input()
	name = ''.join((c for c in str_ if c.isalpha()))
	order.append(name)
for i in range(n):
	if order[n - 1 - i] not in appear:
		appear[order[n - 1 - i]] = 1
		print(order[n - 1 - i])


from collections import OrderedDict as od
l = [input() for _ in range(int(input()))]
l.reverse()
k = list(od.fromkeys(l))
print(*k, sep='\n')


chat = [input() for i in range(int(input()))]
l = {}
while chat:
	t = chat.pop()
	if t not in l:
		l[t] = 0
		print(t)


n = int(input())
names = []
for i in range(n):
	names.append(input())
s = set()
for name in reversed(names):
	if name not in s:
		s.add(name)
		print(name)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	n = Int()
	a = []
	b = []
	for i in range(n):
		a.append(Str())
	for i in range(n - 1, -1, -1):
		b.append(a[i])
	ans = Counter(b)
	an = list(ans.keys())
	for i in range(len(an)):
		print(an[i])
solution()


ts = {}
n = int(input())
for i in range(n):
	u = input()
	ts[u] = i
ts = sorted(map(lambda x: (-x[1], x[0]), ts.items()))
print('\n'.join(map(lambda x: x[1], ts)))


n = int(input())
dict = {}
for i in range(0, n):
	name = str(input())
	dict[name] = i + 1
for key in sorted(dict, key=dict.get, reverse=True):
	print(key)


def main():
	n = int(input())
	friend_dict = {}
	for i in range(n):
		friend_dict[input()] = i
	friend_dict = dict(sorted(friend_dict.items(), key=lambda x: x[1], reverse=True))
	for friend in friend_dict.keys():
		print(friend)
main()


order = []
users_set = set()
count = int(input())
messages = []
for _ in range(count):
	messages.append(input())
for user in reversed(messages):
	if user not in users_set:
		order.append(user)
		users_set.add(user)
print('\n'.join(order))


n = int(input())
St = []
Set = set()
for i in range(n):
	s = input()
	St.append(s)
	Set.add(s)
i = n
while i > 0:
	P = St.pop()
	if P in Set:
		Set.remove(P)
		print(P)
	i -= 1


n = int(input())
names = [input() for _ in range(n)][::-1]
seen = set()
ans = list()
for name in names:
	if name not in seen:
		seen.add(name)
		ans.append(name)
print('\n'.join(ans))


fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from re import *
from sys import *
from math import *
from heapq import *
from queue import *
from bisect import *
from string import *
from itertools import *
from collections import *
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from collections import Counter as cc
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)

def output(answer):
	stdout.write(str(answer))
n = int(z())
ans = set()
lst = []
for i in range(n):
	lst.append(z())
for i in range(1, n + 1):
	if lst[-i] not in ans:
		ans.add(lst[-i])
for i in ans:
	print(i)


n = int(input())
lst = []
while n > 0:
	lst.append(input())
	n -= 1
lst.reverse()
b = set()
for s in lst:
	if s in b:
		continue
	print(s)
	b.add(s)


n = int(input())
d = {}
for i in range(n):
	d[input()] = i
a = [(i[1], i[0]) for i in d.items()]
a.sort(reverse=True)
print(*[i[1] for i in a], sep='\n')


from collections import OrderedDict

def main():
	n = int(input())
	d = OrderedDict()
	for i in range(0, n):
		chat = input()
		if chat in d:
			del d[chat]
		d[chat] = 1
	for chat in reversed(d.keys()):
		print(chat)
main()


(n, a, b) = (int(input()), [], set())
for i in range(n):
	a.append(input())
a.reverse()
for i in a:
	if i not in b:
		print(i)
		b.add(i)


(a, s) = ([input() for i in range(int(input()))], set())
for x in reversed(a):
	if x not in s:
		print(x)
		s.add(x)


n = int(input())
name = input()
dname = dict()
dname[name] = 1
lname = name
for i in range(1, n):
	name = input()
	dname[name] = i + dname[lname]
	lname = name
l = lambda x: x[1]
sd = sorted(list(dname.items()), key=l, reverse=True)
for i in range(len(sd)):
	print(sd[i][0])


from sys import stdin
MAX = 200000 + 5
a = ['' for _ in range(MAX)]
cur = MAX - 1
d = {}
for _ in range(int(stdin.readline())):
	s = stdin.readline().rstrip()
	if s in d:
		a[d[s]] = ''
	a[cur] = s
	d[s] = cur
	cur -= 1
print('\n'.join(filter(lambda x: x, a)))


from sys import stdin, stdout

def main():
	n = int(stdin.readline().strip())
	d = {}
	for i in range(n):
		name = stdin.readline().strip()
		d[name] = i
	outputs = sorted(d.keys(), key=lambda t: d[t], reverse=True)
	for output in outputs:
		print(output)
main()


input()
names = []
while True:
	try:
		names.append(input())
	except:
		break
done = {}
for name in reversed(names):
	if done.get(name, False):
		continue
	print(name)
	done[name] = True


n = int(input())
s = []
for i in range(n):
	s += [input()]
m = set()
for v in reversed(s):
	if v not in m:
		m.add(v)
		print(v)


n = int(input())
D = {}
l = []
ll = []
for i in range(0, n):
	l.append(input())
for i in range(0, n):
	if l[n - i - 1] in D:
		m = 0
	else:
		D[l[n - i - 1]] = 1
		ll.append(l[n - 1 - i])
for i in range(0, len(ll)):
	print(ll[i])


n = int(input())
m = {}
mm = {}
for i in range(n):
	a = input()
	m[a] = i
for j in m:
	mm[m[j]] = j
ans = sorted(mm.keys(), reverse=True)
for i in ans:
	print(mm[i])


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')
g = {}
for i in range(int(input())):
	g[input()] = i
for (i, j) in sorted(g.items(), key=lambda x: x[1], reverse=1):
	print(i)


R = lambda : map(int, input().split())
n = int(input())
ol = [input() for _ in range(n)]
mi = dict()
for (i, w) in enumerate(ol):
	mi[w] = i
for (k, v) in sorted(mi.items(), key=lambda p: p[1], reverse=True):
	print(k)


n = int(input())
l = []
for _ in range(n):
	l.append(input())
t = set()
for i in range(len(l) - 1, -1, -1):
	if l[i] not in t:
		print(l[i])
		t.add(l[i])


n = int(input())
i = 0
O = dict()
A = list()
for i in range(0, n):
	s = input()
	if s in O:
		A[O[s]] = None
	O[s] = i
	A.append(s)
i = len(A) - 1
while i >= 0:
	if A[i]:
		print(A[i])
	i = i - 1


n = int(input())
messages = [''] * n
seen = dict()
aux = ''
for i in range(n):
	aux = input()
	messages[i] = aux
	try:
		if seen[aux] != 0:
			seen[aux] = 0
	except KeyError:
		seen[aux] = 0
res = []
for i in range(len(messages) - 1, -1, -1):
	aux2 = messages[i]
	if seen[aux2] == 0:
		seen[aux2] = 1
		print(aux2)


n = int(input())
displayed = {}
top = None
for i in range(n):
	chat = input()
	try:
		a = displayed[chat]
		previous = a[0]
		nextone = a[1]
		if previous:
			displayed[previous][1] = nextone
			if nextone:
				displayed[nextone][0] = previous
			displayed[chat] = [None, top]
			if top:
				displayed[top][0] = chat
			top = chat
	except KeyError:
		displayed[chat] = [None, top]
		if top:
			displayed[top][0] = chat
		top = chat
li = []
while top:
	li.append(top)
	top = displayed.pop(top)[1]
print('\n'.join(li))


from sys import stdin, stdout
n = int(stdin.readline())
d = dict()
s = ''
z = [stdin.readline() for _ in ' ' * n][::-1]
for i in z:
	if d.get(i, 0) == 0:
		d[i] = 1
		s += i
stdout.write(s)


stack = []
s = set()
l = []
for _ in range(int(input())):
	stack.append(input())
while len(stack) != 0:
	x = stack.pop()
	if x not in s:
		s.add(x)
		l.append(x)
for i in l:
	print(i)


from collections import *
d = OrderedDict()
n = int(input())
l = [input() for i in range(n)][::-1]
for x in l:
	d[x] = d.get(x, 0) + 1
for x in d:
	print(x)


N = int(input())
L = []
D = {}
for i in range(N):
	L.append(input())
for i in reversed(range(len(L))):
	if L[i] not in D:
		D[L[i]] = 1
		print(L[i])


n = int(input())
l1 = []
d = dict()
for i in range(n):
	x = input()
	l1.append(x)
	d[x] = 0
for j in range(n - 1, -1, -1):
	v = l1[j]
	if d[v] == 0:
		print(v)
		d[v] = 1


n = int(input())
d = {}
L = []
for i in range(n):
	S = str(input())
	d[S] = n - i - 1
L = [0] * n
for i in d:
	L[d[i]] = i
for i in L:
	if i != 0:
		print(i)


n = int(input())
l = [input() for i in range(n)]
s = dict()
a = {}
for i in range(n - 1, -1, -1):
	if l[i] not in s:
		print(l[i])
		s[l[i]] = 1


A = []
for i in range(int(input())):
	A.append(input().strip())
names = set()
for i in range(len(A) - 1, -1, -1):
	if not A[i] in names:
		names.add(A[i])
		print(A[i])


n = int(input())
result = set()
a = [input() for i in range(n)][::-1]
for j in range(len(a)):
	if not a[j] in result:
		print(a[j])
		result.add(a[j])


n = int(input())
a = {}
for i in range(n):
	b = input()
	a[b] = i
b = {}
for i in a.keys():
	b[a[i]] = i
c = sorted(b.keys(), reverse=True)
for i in c:
	print(b[i])


n = int(input())
d = dict()
for i in range(n):
	d[input()] = i
lst = list(d.items())
lst.sort(key=lambda x: -x[1])
for i in lst:
	print(i[0])


n = int(input())
D = {}
for i in range(n):
	D[input()] = i
for a in sorted(D, key=D.get, reverse=True):
	print(a)


n = int(input())
talkers = [input() for i in range(n)]
d = {}
for (i, man) in enumerate(talkers):
	d[man] = i
chats = list(d.items())
chats.sort(key=lambda x: -x[1])
for (man, i) in chats:
	print(man)


n = int(input())
d = {}
p = 1
for _ in range(n):
	s = input()
	d[s] = p
	p += 1
t = []
for (k, v) in d.items():
	t.append((v, k))
t = sorted(t, reverse=True)
for e in t:
	print(e[1])


n = int(input())
messages = []
for i in range(n):
	messages.append(input())
ans = set()
Prt = []
for i in messages[::-1]:
	if not i in ans:
		ans.add(i)
		Prt.append(i)
print('\n'.join(Prt))


n = int(input())
s = dict()
k = []
for _ in range(n):
	p = input()
	s[p] = 0
	k.append(p)
c = len(s)
while c > 0:
	p = k.pop()
	if s[p] == 0:
		s[p] = 1
		c -= 1
		print(p)


n = int(input())
s = [input() for _ in range(n)]
l = set()
for x in reversed(s):
	if x not in l:
		print(x)
		l.add(x)


uniq = {}
n = int(input())
s = [0] * n
for i in range(n):
	s[i] = input()
for i in s[::-1]:
	if i not in uniq:
		print(i)
		uniq[i] = 1


n = int(input())
rank = n
li = [0] * (n + 1)
for i in range(n, 0, -1):
	s = input()
	li[i] = s
dp = dict()
for i in range(1, n + 1):
	if dp.get(li[i], 0) == 0:
		dp[li[i]] = 1
		print(li[i])


n = int(input())
arr = []
for i in range(n):
	s = input()
	arr.append(s)
st = {''}
for i in range(n):
	s = arr.pop()
	if s not in st:
		st.add(s)
		print(s)


n = int(input())
l = [input() for i in range(n)]
m = set()
for i in range(n - 1, -1, -1):
	if l[i] not in m:
		print(l[i])
		m.add(l[i])


n = int(input())
p = [0] * n
for i in range(n):
	p[i] = input()
last_occurance = {}
for i in range(n):
	last_occurance[p[i]] = i
r = len(last_occurance)
l1 = list(last_occurance.keys())
l1.sort(key=lambda x: last_occurance[x])
for i in range(r):
	print(l1[r - 1 - i])


from sys import stdin
input()
arr = stdin.read().splitlines()
st = set()
ans = []
for i in arr[::-1]:
	if not i in st:
		ans.append(i)
		st.add(i)
print('\n'.join(ans))


def main():
	n = int(input())
	a = []
	for i in range(n):
		a.append(input())
	used = set()
	ans = []
	for i in range(n - 1, -1, -1):
		if a[i] not in used:
			ans.append(a[i])
			used.add(a[i])
	for person in ans:
		print(person)
main()


nomes = [input() for i in range(int(input()))]
nomes.reverse()
lista = set(nomes)
for i in nomes:
	if i in lista:
		print(i)
		lista.remove(i)


import collections
dq = collections.deque()
n = int(input())
for i in range(n):
	x = input()
	dq.appendleft(x)
mp = dict()
for i in range(n):
	if dq[i] not in mp.keys():
		print(dq[i])
		mp[dq[i]] = 1


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline()

def main():
	from collections import OrderedDict
	d = OrderedDict()
	n = int(input())
	arr = [0] * n
	for i in range(n):
		arr[i] = input().strip()
	for i in reversed(arr):
		if i not in d:
			d[i] = 1
	print(*d, sep='\n')
main()


n = int(input())
a = []
b = {}
c = {}
for i in range(n):
	a.append(input())
a.reverse()
b = {}
for i in a:
	b[i] = 0
for i in range(n):
	if b[a[i]] == 0:
		print(a[i])
		b[a[i]] = 1


n = int(input())
a = set()
res = []
names_arr = []
for i in range(n):
	name = input()
	names_arr.append(name)
for i in range(1, len(names_arr) + 1):
	cur_name = names_arr[-i]
	if cur_name not in a:
		a.add(cur_name)
		res.append(cur_name)
for i in range(len(res)):
	print(res[i])


n = int(input())
d = {}
for i in range(n):
	s = input()
	if s not in d:
		d[s] = 0
	else:
		del d[s]
		d[s] = 0
ans = list(d.keys())[::-1]
for j in ans:
	print(j)


def main():
	d = {input(): i for i in range(int(input()))}
	print('\n'.join(sorted(d.keys(), key=d.get, reverse=True)))
main()


n = int(input())
A = []
B = set()
for i in range(n):
	s = input()
	A.append(s)
	B.add(s)
i = n
while i > 0:
	p = A.pop()
	if p in B:
		B.remove(p)
		print(p)
	i = i - 1


import operator
N = int(input())
D = {input(): -i for i in range(N)}
for (key, value) in sorted(D.items(), key=operator.itemgetter(1)):
	print(key)


n = int(input())
x = []
for _ in range(n):
	x.append(input())
x = x[::-1]
ans = set()
l = len(set(x))
for i in x:
	if len(ans) < l:
		if i not in ans:
			ans.add(i)
			print(i)
	else:
		break


n = int(input())
dic = {}
li = []
for x in range(n):
	temp = input()
	dic[temp] = 0
	li.append(temp)
li.reverse()
for x in li:
	if dic[x] == 0:
		print(x)
		dic[x] = -1


def get_chats(names):
	chats = {}
	for name in reversed(names):
		if name not in chats:
			print(name)
			chats[name] = True
len = int(input())
names = []
for i in range(len):
	names.append(input())
get_chats(names)


message_count = int(input())
names = {}
last = 1
for i in range(message_count):
	name = input()
	names[name] = -i
sorted_names = sorted(names.keys(), key=lambda name: names[name])
[print(name) for name in sorted_names]


from sys import stdin
inp = stdin.readline
n = int(inp())
uniq = set()
chat_list = []
for _ in range(n):
	name = inp().strip()
	uniq.add(name)
	chat_list.append(name)
uniq_len = len(uniq)
uniq.clear()
cur_len = 0
n -= 1
ans = []
while cur_len != uniq_len:
	if chat_list[n] not in uniq:
		ans.append(chat_list[n])
		uniq.add(chat_list[n])
		cur_len += 1
	n -= 1
print('\n'.join(ans))


n = int(input())
a = {}
for i in range(n):
	a[input()] = i
for (name, _) in sorted(a.items(), key=lambda x: -x[1]):
	print(name)


n = int(input())
name = {}
for i in range(n):
	t = input()
	name[t] = i
	name[i] = t
for i in range(n)[::-1]:
	if name[name[i]] == i:
		print(name[i])


set1 = set()
lst = list()
for i in range(int(input())):
	lst.append(input())
r = len(lst)
for i in range(1, r + 1):
	if lst[r - i] in set1:
		pass
	else:
		print(lst[r - i])
		set1.add(lst[r - i])


s = set()
d = {}
n = int(input())
j = n
for i in range(n):
	a = input()
	if a not in s:
		s.add(a)
		d[j] = a
	else:
		d[j] = a
	j -= 1
for i in range(1, n + 1):
	if i in d and d[i] in s:
		print(d[i])
		s.remove(d[i])


import sys
inp = sys.stdin.read().strip().splitlines()
was = set()
answer = []
for name in inp[-1:0:-1]:
	if name not in was:
		was.add(name)
		answer.append(name)
print('\n'.join(answer))