P6447 [COCI 2010/2011 #1] ŽABE

Description

The king has $n$ servants. He arranges the servants in a circle, and each servant faces the back of the next servant. Each servant has an ID number, and the sequence always starts from the servant with ID $1$. If a servant moves in front of the servant directly in front of them, this operation is considered cutting in line. For example, if the servants are `1 5 4 3 2 6`, and the servant with ID $2$ cuts forward by $2$ positions, the result becomes `1 2 5 4 3 6`. > Note: Everyone faces to the right of the sequence. When the king announces a number $b$, the servant with ID $b$ must cut forward by $b$ positions. The king wants to announce some commands to transform the initial sequence into his desired sequence. Given the initial sequence and the king's desired sequence, you need to output the commands issued by the king in order. The testdata guarantees that the initial sequence and the king's desired sequence are not the same.

Input Format

The input consists of three lines. The first line contains an integer $n$, as described above. The second line contains $n$ integers $a_i$, representing the initial sequence. The third line contains $n$ integers $k_i$, representing the king's desired sequence.

Output Format

Output $m$ lines. Each line contains an integer $b$, as described above. Note: $m$ is the number of operations performed by the king.

Explanation/Hint

**Explanation of Sample Input/Output 1** If the servants are `1 5 4 3 2 6`, and the servant with ID $2$ cuts forward by $2$ positions, the result becomes `1 2 5 4 3 6`. --- **Constraints** For $100\%$ of the testdata, $3 \leq n \leq 100$, $1 \leq m \leq 10^5$, $1 \leq a_i,k_i \leq 100$, $1 \leq b \leq n$. --- **Notes** **This problem is translated from [COCI2010-2011](https://hsin.hr/coci/archive/2010_2011/) [CONTEST #1](https://hsin.hr/coci/archive/2010_2011/contest1_tasks.pdf) *T6 ŽABE*.** Thanks to [我谔谔](/user/127284) for providing the Special Judge. Thanks to [aaron0919](/user/818165) for fixing an error. Translated by ChatGPT 5