Due to her thirst for power, Sashka decided to create a new country. It will span across the territories of Bulgaria, which can be represented as a network of regions, numbered to , connected by roads. From every region it is possible to reach every other region using the roads. Sashka’s country will span across several (one or more) regions such that they are connected. Regions are connected when there is a path between any two of the chosen regions on which no unchosen region lies.
The most recent census established that the -th region has inhabitants. Thus, the population of Sashka’s country will be the sum of the individual populations of the chosen regions. Since it would be terribly boring for Sashka to consider just one variant of her country, she will consider all possible ones. She wants to find the sum of the populations over all possible choices of country. Write a program territory that finds this value. Since the sum may be too large, find its remainder when divided by .
Input data
On one line of standard input the positive integer is given. On the next line positive integers are given. On the remaining lines the road network is described: the -th of these lines contains the integers and , characterising a road between region and region .
Output data
On standard output print the required value.
Constraints and clarifications
| Subtask | Required subtasks | Points | Additional constraints | |
|---|---|---|---|---|
| 0 | - | 0 | - | Sample tests. |
| 1 | 0 | 15 | - | |
| 2 | - | 10 | ||
| 3 | 0-1 | 35 | - | |
| 4 | 0-3 | 40 | - |
Example 1
stdin
6
1 4 9 16 25 36
1 2
2 3
3 4
4 5
5 6
stdout
812
Explanation
Bulgaria is indicated in the image.

Example 2
stdin
7
10 7 5 8 4 6 9
2 7
2 5
7 1
6 5
7 4
3 5
stdout
864
Explanation
Bulgaria is indicated in the image.
