#d1702. 数字替换

数字替换

Number Replacement

Problem Description

Maintain a number sequence, initially empty.

There are qq operations in total, of two types:

  • 1 x — append the number xx to the end of the sequence.
  • 2 x y — replace the value of every number currently equal to xx in the sequence with yy.

After the qq operations, output the sequence.

Input Format

The first line contains an integer qq, the number of operations.

Lines 22 to q+1q+1 each describe one operation.

Output Format

One line containing the final sequence.

Sample Input

7
1 3
1 1
2 1 2
1 2
1 1
1 2
2 1 3

Sample Output

3 2 2 3 2

Constraints

1≤q,x,y≤5×1051 \le q, x, y \le 5 \times 10^5