#C3758. Reconstructing Drone Delivery Routes

    ID: 47220 Type: Default 1000ms 256MiB

Reconstructing Drone Delivery Routes

Reconstructing Drone Delivery Routes

In this problem, you are given the logged delivery route of a drone. Due to multiple visits to the same delivery point, the logged route may contain repeated entries. Your task is to reconstruct the intended unique route by removing duplicate delivery points, while maintaining the order of their first occurrence.

The input consists of multiple test cases. For each test case, the first line contains an integer \(n\) which indicates the total number of expected unique delivery points. The next line contains a sequence of integers representing the logged route. A test case with \(n = 0\) indicates the end of input.

For example, given the logged route:

[ [1, 2, 3, 2, 4, 5, 3, 2, 1, 4, 5] ]

The reconstructed unique delivery route is:

[ [1, 2, 3, 4, 5] ]

inputFormat

The input is read from standard input (stdin) and consists of multiple test cases. Each test case is defined as follows:

  1. An integer \(n\) (\(n > 0\)) on a single line representing the total number of unique delivery points.
  2. A line containing a series of space-separated integers representing the logged delivery route which may include repeated points.

The input terminates with a test case where \(n = 0\); this test case should not be processed.

outputFormat

For each test case, output a single line containing the space-separated sequence of unique delivery points in the order they first appear in the logged route.

## sample
5
1 2 3 2 4 5 3 2 1 4 5
4
1 3 2 3 4 1
0
1 2 3 4 5

1 3 2 4

</p>