We have a country with cities. The cities in this country are connected by two-way roads. We know that from each city, we can reach any other city by traversing some roads, meaning the structure of this country is a tree.
The cities are numbered from to . We know the population of city is . The \textit{difference} between two cities is defined as the XOR of the populations of the cities along the path between the two cities (including the start and end). The \textit{value} of the country is the sum of the differences between every pair of distinct cities.
Calculating the initial value of the country is not a hard task for the mayor. Therefore, we ask you to design a dynamic system. You will receive queries.
In each query, the population of city changes to . We want you to write a program that calculates the initial value of the country and the value of the country after each change.
The first line of input contains an integer , representing the number of cities in the country.
The second line contains integers , representing the initial population of each city.
Each of the next lines contain two integers and , representing a road between cities and in the country.
The following line contains an integer , representing the number of queries.
The next lines each contain two integers and , representing an operation that changes the population of city to . It is guarantied that the roads form a tree.
The output consists of lines, where each line contains an integer representing the current value of the country.