CF637B Chat Order

题目描述

有一个队列,初始时为空。现在依次插入 $n$ 个单词,如果这个单词已经在队列中,那就把这个单词从原来位置移到队首,否则直接把这个单词放到队首。问你最后这个队列长啥样。

输入格式

第一行,一个整数 $n$ ( $1 \le n \le 200000 $),表示单词的数量。接下来 $n$ 行,每行一个单词,每个单词都由小写字母构成,非空且长度均不超过 $10$ 。

输出格式

若干行,每行一个单词,依次表示从队首到队尾的每个单词。

说明/提示

In the first test case Polycarpus first writes to friend by name "alex", and the list looks as follows: 1. alex Then Polycarpus writes to friend by name "ivan" and the list looks as follows: 1. ivan 2. alex Polycarpus writes the third message to friend by name "roman" and the list looks as follows: 1. roman 2. ivan 3. 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: 1. ivan 2. roman 3. alex