Universal Cup Judging System

Universal Cup

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 100
統計

Alice and Bob have $2n$ cards, each with an integer written on it, such that each integer between $1$ and $n$ appears on exactly two cards. Initially, Alice and Bob each hold $n$ cards.

They are going to play a card game, with Alice going first. On each turn, the current player places a card from their hand on top of the pile. If there are now two cards with the same number in the pile, the current player scores $1$ point and removes the two matching cards along with all cards in between, placing them in the discard pile.

Given Alice's sequence of moves, how can Bob arrange his moves to minimize Alice's score?

Input

The first line contains an integer $T$ ($1 \le T \le 10^5$), indicating the number of test cases.

For each test case, the first line contains an integer $n$ ($1 \le n \le 5 \times 10^5$).

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$), representing the numbers on the cards played by Alice in order. It is guaranteed that no number appears more than twice in $a_i$.

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \times 10^5$.

Output

For each test case, the first line of output should contain an integer, representing the minimum score Alice can get.

The second line should contain $n$ integers $b_1, b_2, \dots, b_n$ ($1 \le b_i \le n$), representing Bob's moves in order, such that each integer from $1$ to $n$ appears exactly twice in the combined sequences of $a_i$ and $b_i$.

Example

Input

3
3
1 2 3
5
3 1 4 1 5
5
1 4 5 1 4

Output

0
1 2 3
0
2 3 2 4 5
1
3 2 2 3 5

Note

For the third test case, the game proceeds as follows:

Step Player Card Played Pile from Bottom to Top Alice's Score Bob's Score
$1$ Alice $1$ $[1]$ $0$ $0$
$2$ Bob $3$ $[1, 3]$ $0$ $0$
$3$ Alice $4$ $[1, 3, 4]$ $0$ $0$
$4$ Bob $2$ $[1, 3, 4, 2]$ $0$ $0$
$5$ Alice $5$ $[1, 3, 4, 2, 5]$ $0$ $0$
$6$ Bob $2$ $[1, 3, 4]$ $0$ $1$
$7$ Alice $1$ $[]$ $1$ $1$
$8$ Bob $3$ $[3]$ $1$ $1$
$9$ Alice $4$ $[3, 4]$ $1$ $1$
$10$ Bob $5$ $[3, 4, 5]$ $1$ $1$

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.