We all know our dear friend - Leba Non. Playboy, billionaire, philanthropist, and also the creator of ACC tasks. This task is about him.
While creating the tournament tasks, the evil villain Bashkirov Daniil locked all the jury members in cages. For communication, there is a one-way tunnel from each cage to another. Initially, the $$$i$$$-th jury member sits in cage $$$i$$$. But for things to work efficiently, each jury member needs to be well-fed. For this, Daniil entrusted Leba Non with one task - to feed all the jury members. To do this, Leba Non decided to organize $$$q$$$ dinners. Each dinner is held in one of the cages. If a jury member can reach the cage with dinner, he goes there and does not return. The distance between cages is the number of tunnels that make up the path between them. Help Leba Non calculate the total distance that each jury member will travel.
The first line contains one number $$$n$$$ - the number of jury members. ($$$1 \le n \le 2\cdot 10^{5}$$$)
The second line contains $$$n$$$ numbers $$$a_i$$$ - the cage to which the tunnel from cage $$$i$$$ leads. ($$$1 \le a_i \le n$$$)
The third line contains one number $$$q$$$ - the number of dinners. ($$$1 \le q \le 2\cdot 10^{5}$$$)
The last line contains $$$q$$$ numbers $$$b_j$$$ - the cage where the $$$j$$$-th dinner takes place. ($$$1 \le b_j \le n$$$)
On one line, output $$$n$$$ numbers - the total distance that each jury member will travel.
10 2 3 4 5 1 3 6 6 7 7 8 7 6 3 1 5 1 2 4
13 12 11 15 14 12 13 13 14 14
10 2 3 4 5 1 3 6 6 7 7 2 6 7
0 0 0 0 0 0 1 1 2 2
5 2 5 5 3 3 5 2 3 5 2 5
4 3 1 2 2