#P6447. [COCI 2010/2011 #1] ŽABE

[COCI 2010/2011 #1] ŽABE

Description

The king has nn 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 11. 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 22 cuts forward by 22 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 bb, the servant with ID bb must cut forward by bb 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 nn, as described above.

The second line contains nn integers aia_i, representing the initial sequence.

The third line contains nn integers kik_i, representing the king's desired sequence.

Output Format

Output mm lines.

Each line contains an integer bb, as described above.

Note: mm is the number of operations performed by the king.

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

Hint

Explanation of Sample Input/Output 1

If the servants are 1 5 4 3 2 6, and the servant with ID 22 cuts forward by 22 positions, the result becomes 1 2 5 4 3 6.


Constraints

For 100%100\% of the testdata, 3n1003 \leq n \leq 100, 1m1051 \leq m \leq 10^5, 1ai,ki1001 \leq a_i,k_i \leq 100, 1bn1 \leq b \leq n.


Notes

This problem is translated from COCI2010-2011 CONTEST #1 T6 ŽABE.

Thanks to 我谔谔 for providing the Special Judge.

Thanks to aaron0919 for fixing an error.

Translated by ChatGPT 5