#P6569. [NOI Online #3 提高组] 魔法值

[NOI Online #3 提高组] 魔法值

Problem Description

The transportation system of Country H consists of nn cities and mm roads. Both cities and roads are numbered starting from 11, and City 11 is the capital of Country H. In Country H, each road directly connects two different cities, and there is at most one road between any two cities.

Country H is a nation that believes in magic. On day jj, the magic value of City ii is fi,jf_{i,j}. The wizards of Country H have observed the magic values fi,0f_{i,0} of all cities on day 00. They also found that on each following day, the magic value of every city will become the XOR of the previous day's magic values of all cities directly connected to it, that is,

$$f_{x,j}=f_{v_1,j-1}\oplus f_{v_2,j-1}\oplus \cdots\oplus f_{v_k,j-1}$$

where j1j\ge 1, v1,v2,,vkv_1, v_2, \cdots, v_k are all cities directly connected to City xx, and \oplus denotes the XOR operation.

Now the king of Country H asks you qq questions. For the ii-th question (1iq1\le i\le q), you need to answer: what is the magic value of the capital on day aia_i.

Input Format

The first line contains three integers n,m,qn, m, q separated by spaces, representing the number of cities, the number of roads, and the number of questions.

The second line contains nn integers separated by spaces, where the ii-th integer represents fi,0f_{i, 0}.

The next mm lines each contain two positive integers u,vu, v separated by spaces, indicating a road connecting City uu and City vv.

The next qq lines each contain one integer. The integer on the ii-th line represents aia_i.

Output Format

Output qq lines in order, each containing one integer, representing the answer to the corresponding question.

3 3 1
0 0 1
1 2
1 3
2 3
1

1

Hint

Constraints

  • For 20%20\% of the testdata, ai100a_i \leq 100.
  • For 40%40\% of the testdata, n20n \leq 20.
  • Another 30%30\% of the testdata satisfies m=n(n1)2m=\frac{n(n-1)}{2}.
  • For 100%100\% of the testdata, 1n,q1001 \leq n, q \leq 100, 1mn(n1)21 \leq m \leq \frac{n(n-1)}{2}, 1ai<2321\leq a_i < 2^{32}, 0fi,0<2320\leq f_{i,0} < 2^{32}.

Notes

data provider: @一扶苏一. If there are issues with the data, please contact her. If it gets accepted by a naive fast exponentiation solution, please also contact her.

Translated by ChatGPT 5