Removing duplicates from a list of strings

Java Easy collections

Task «Removing duplicates from a list of strings»

Write a program that reads lines from standard input, stores them in an ArrayList, and then removes all duplicates, leaving only unique elements in the order of their first appearance. Print the resulting list of strings separated by a space.

Input Format

The first line contains an integer n (1 ≤ n ≤ 1000) — the number of strings. Then follow n strings, each on a separate line.

Output Format

One line containing unique strings from the original list in the order of their first occurrence, separated by a space.

Examples

Example 1

INPUT
3 hello world hello
OUTPUT
hello world
main.java