Botanist Somhed regularly takes groups of students to one of Thailand's largest tropical gardens. The landscape of this garden is composed of fountains (numbered ) and trails. Each trail connects a different pair of distinct fountains, and can be traveled in either direction. There is at least one trail leaving each fountain. These trails feature beautiful botanical collections that Somhed would like to see. Each group can start their trip at any fountain.

Somhed loves beautiful tropical plants. Therefore, from any fountain he and his students will take the most beautiful trail leaving that fountain, *unless* it is the most recent trail taken and there is an alternative. In that case, they will take the second most beautiful trail instead. Of course, if there is no alternative, they will walk back, using the same trail for the second time. Note that since Somhed is a professional botanist, no two trails are considered equally beautiful for him.

His students are not very interested in the plants. However, they would love to have lunch at a premium restaurant located beside fountain number . Somhed knows that his students will become hungry after taking exactly trails, where could be different for each group of students. Somhed wonders how many different routes he could choose for each group, given that:

- each group can start at any fountain;
- the successive trails must be chosen in the way described above; and
- each group must finish at fountain number after traversing exactly trails.

Note that they may pass fountain number earlier on their route, although they still need to finish their route at fountain number .

#### Your task

Given the information on the fountains and the trails, you have to find the answers for groups of students; that is, values of .

Write a program that takes the following parameters:

- – the number of fountains. The fountains are numbered through .
- – the number of trails. The trails are numbered through . The trails will be given in decreasing order of beauty: for , trail is more beautiful than trail .
- – the fountain at which the premium restaurant is located.
- – a two-dimensional array representing the trails. For , trail connects the fountains and . Recall that each trail joins a pair of distinct fountains, and no two trails join the same pair of fountains.
- – the number of groups of students.
- – a one-dimensional array of integers containing the values of . For , is the number of trails that the -th group will take.

For , your program must find the number of possible routes with exactly trails that group could possibly take to reach fountain . For each group , your procedure should output to report that the number of routes is . The answers must be given in the same order as the groups. If there are no valid routes, your program must output `0`

.

#### Examples

##### Example 1

Consider the case shown in Figure 1, where , , , , , and .

Note that trails are listed in decreasing order of beauty. That is, trail is the most beautiful one, trail is the second most beautiful one, and so on. There are only two possible valid routes that follow 3 trails:

- , and
- .

The first route starts at fountain . The most beautiful trail from here leads to fountain . At fountain , the group has no choice, they must return using the same trail. Back at fountain , the group will now avoid trail and choose trail instead. This trail does indeed bring them to the fountain .

Thus, the program should call output `2`

.

##### Example 2

Consider the case shown in Figure 2, where , , , , , , and .

For the first group, there is only one valid route that reaches fountain after following trails: .

For the second group, there are two valid routes that reach fountain after following trail: , and .

Therefore, a correct program should first output `1`

to report the answer for the first group, and then call output `2`

to report the answer for the second group.

#### Input Specification

- Line : , , and
- Lines to : description of the trails; i.e., line contains and , separated by a space, for .
- Line : .
- Line : array as a sequence of space-separated integers.

#### Output Specification

One line containing space separated integers.

#### Sample Input 1

```
5 5 2
1 0
1 2
3 2
1 3
4 2
2
3 1
```

#### Sample Output 1

`1 2`

#### Sample Input 2

```
6 6 0
1 2
0 1
0 3
3 4
4 5
1 5
1
3
```

#### Sample Output 2

`2`

#### Subtasks

##### Subtask 1 (49 points)

- each element of is an integer between and , inclusive.

##### Subtask 2 (20 points)

- each element of is an integer between and , inclusive.

##### Subtask 3 (31 points)

- each element of is an integer between and , inclusive.

## Comments