Frog Leaps

Time limit1sMemory limit128 MB

Problem

The Frog Regent has arranged his $N$ frog servants in a circle, each frog facing the back of the frog directly ahead of it. Every frog carries a unique integer ID from $1$ to $N$.

The arrangement is written as a sequence of IDs that always begins with the frog whose ID is $1$, followed by the frog directly ahead of it, then the next frog ahead, and so on all the way around the circle, ending with the frog directly behind frog $1$.

A frog performs one leap by jumping over the single frog directly ahead of it, swapping places with that frog. Because the frogs stand in a circle, the frog directly ahead of the last one in the written sequence is frog $1$ again. When the Regent proclaims a number $B$, the frog whose ID is $B$ performs exactly $B$ leaps, one after another.

For example, from the arrangement 1 5 4 3 2 6, proclaiming $2$ makes frog $2$ perform $2$ leaps and the arrangement becomes 1 2 5 4 3 6. The arrangement is always rewritten so that it starts with frog $1$.

The Regent will issue a list of proclamations, one after another. Given the starting arrangement and the whole list of proclamations, determine the final arrangement of the frogs once every proclamation has been carried out in order.

Input

The first line contains an integer $N$, the number of frogs ($3 \le N \le 100$).

The second line contains a permutation of the integers $1$ through $N$: the starting arrangement, beginning with frog $1$.

The third line contains an integer $Q$, the number of proclamations ($0 \le Q \le 100,000$).

The fourth line contains $Q$ integers $B_1, B_2, \dots, B_Q$ ($1 \le B_i \le N$), the proclamations in the order the Regent issues them. If $Q = 0$, this line is empty.

Output

Output one line with the final arrangement after all proclamations have been applied: $N$ integers separated by single spaces, written so that the sequence begins with frog $1$.