Universal Cup Judging System

Universal Cup

Time Limit: 3.0 s Memory Limit: 512 MB Total points: 100
Statistics

After wandering around for quite a while, Iroha arrived at a mysterious place in the Moon Reading Space — the Kingdom of Construction.

Having heard that you had once been here, Iroha was very happy and shared with you an interesting memory from the Kingdom of Construction.

In the Kingdom of Construction, there is a magical deck of cards. It has exactly $n$ different ranks (represented by integers from $1$ to $n$), and each rank appears exactly twice. After a uniform shuffle, these $2n$ cards form a deck. In other words: the input data guarantees that the deck is generated uniformly at random from all valid decks containing $n$ ranks, with exactly two cards of each rank.

In this space, Iroha is granted a very powerful ability: generating stacks. Since this ability is very exhausting, Iroha can generate only $260$ stacks.

Now, Iroha needs to take the cards from the original deck one by one in order from top to bottom. For each card taken out, Iroha may put it onto the top of any stack.

After all $2n$ cards have been placed, Iroha's stacks must satisfy the following condition: it must be possible to perform several "elimination operations" until all cards are eliminated:

  • Each operation chooses two different stacks. If the top cards of these two stacks have the same rank, then these two cards are popped (removed) simultaneously.

Unfortunately, Iroha could not solve this problem, so she handed it over to the smart and experienced you, hoping that you could help her.

To make it easier for you, you do not need to give the actual elimination process. You only need to output, for each card in the original deck order, which stack it is placed onto. Iroha will help you check whether your construction is correct.

Input

The first line contains a positive integer $n$ ($1 \le n \le 5 \times 10^5$), denoting the number of card ranks.

The second line contains $2n$ positive integers $a_1, a_2, \dots, a_{2n}$ ($1 \le a_i \le n$), representing the ranks of the cards in the original deck from top to bottom. It is guaranteed that each rank in $\{1, 2, \dots, n\}$ appears exactly twice.

It is guaranteed that there are exactly $50$ tests (including the sample), and in each test, the array $a$ is chosen uniformly at random from all sequences of length $2n$ in which each rank in $\{1, 2, \dots, n\}$ appears exactly twice.

Output

Output one line containing $2n$ positive integers $c_1, c_2, \dots, c_{2n}$, where $1 \le c_i \le 260$, indicating that the $i$-th card taken from the original deck is put into the $c_i$-th stack.

If there are multiple valid solutions, output any of them.

Example

input

3
1 2 3 1 3 2

output

1 1 1 2 2 3

Note

After processing your command, the last $257$ stacks are empty, and the first $3$ stacks are as follows (elements are listed from bottom to top):

  1. $[1, 2, 3]$,
  2. $[1, 2]$, and
  3. $[3]$.

It is easy to prove that there exists a way to eliminate all cards.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#3281EditorialOpenNew Editorial for Problem #18440wangmaruiView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.