Ants

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Your are given a tree with vertices numbered from 11 to nn. There are ants in the vertices of the tree. Initially, at each vertex ii, there is one ant having index ii.

You will be given qq queries. Each query jj contains an index a_ja\_j of an ant that needs help. During query jj, each ant goes to an adjacent vertex that is closest to ant a_ja\_j, or does not move if they are located at the same vertex. After each query, print the total number of pairs of ants which are located at the same vertex.

Note that the changes persist between queries: for example, when the ants have to move to ant a_2a\_2, they are already in the positions after moving to ant a_1a\_1. Also note that each query requires to move to ant a_ja\_j, which was at vertex a_ja\_j initially, but can be in some other vertex at the time of the query.

입력

The first line of input contains an integer nn, the size of the tree (2n1052 \le n \le 10^5).

Each of the next n1n - 1 lines contains two integers uu and vv describing an edge of the tree (1u,vn1 \le u, v \le n). It is guaranteed that the edges form a tree.

The next line contains an integer qq, the number of queries (1q1051 \le q \le 10^5).

The next qq lines contain integers a_1,a_2,,a_qa\_1, a\_2, \ldots, a\_q, one per line: the numbers of ants in the queries (1a_jn1 \le a\_j \le n).

출력

For each query, print a single line with the answer to it: the number of pairs of ants which are located at the same vertex after this query.