URI Online Judge | 3072
# Dating

**Timelimit: 3**

By Serbia

This story is happening in a town named BubbleLand. There are n houses in BubbleLand. In each of these **N**(1 ≤ **N** ≤ 10^{5}) houses lives a boy or a girl. People there really love numbers, and everyone has a favorite number **F**. That means that the boy or the girl that lives in the **i − th** house has a favorite number equal to **F _{i}**(1 ≤

The houses are numerated with numbers from 1 to **N**.

The houses are connected with **N** **− 1** bi-directional roads and you can travel from any house to any other house in the town. There is exactly one path between every pair of houses.

A new dating agency had opened their offices in BubbleLand and the citizens were very excited. They immediately sent **Q**(1 ≤ **Q** ≤ 10^{5})** **questions to the agency and each question was in the following format:

**A _{B}** – asking how many ways there are to choose a couple (boy and girl) that have the same favorite number and live in one of the houses on a unique path from house

Help the dating agency answer the questions and grow their business.

The first line contains an integer n, the number of houses in the town.

The second line contains n integers, where the **i-th** number is 1 if a boy lives in the **i-th** house or 0 if
a girl lives in the **i-th** house.

The third line contains **N** integers, where the **i-th** number represents the favorite number **F _{i}** of the girl
or the boy that lives in the

The next

The following line contains an integer

Each of the following

For each of the **Q** questions output a single number, the answer to the citizens’ questions.

Input Sample | Output Sample |

7 |
2 3 |