All problems

First Occurrence Wins

mediumPythonData CleaningSetsLists

Calderwood Removals builds the day's call list straight out of the booking system, and a customer who booked twice appears twice. The team works down the list from the top in booking order, which is deliberate: whoever booked earliest gets called first. So the repeats have to come out, but each surviving customer has to stay exactly where their first booking put them.

Task: Print each customer name once, in the position where it first appeared.

Input

The first line holds one integer n, how many names follow. Each of the next n lines holds one customer name. A name may appear any number of times, and the repeats are not necessarily next to each other.

Output

One line per distinct name, in the order each name first appeared in the log. Do not sort them.

Example:

Input:
5
ana
ben
ana
cy
ben

Output:
ana
ben
cy

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…