##### Canadian Computing Competition: 2014 Stage 2, Day 1, Problem 2

King Gruff the Wolf rules over a happy, prosperous land inhabited by adorable Foxen. Unfortunately for them, he is not a nice king at all, and wants to make their lives miserable!

His country has () cities, with () roads running amongst them. The -th road allows one to travel from city to a different city (), in that direction only, and has a length of () and a shutdown cost of (). There may be multiple roads running between a pair of cities, even in the same direction.

King Gruff particularly dislikes the Foxen living in two different cities and (), and would like to make it more inconvenient (or even impossible) to travel from city to city . In particular, he'll select a distance value (), and then simultaneously shut down every single road in his kingdom which is part of at least one path from city to city with total length no more than . For each such road, however, he'll have to dig into his royal treasury and pay its shutdown cost. A path consists of a sequence of roads such that each road (except the first) starts at the city that the previous road ended at, and may visit a city or road multiple times.

Gruff is having trouble making up his mind about what value of to choose, however - a larger value would make things more inconvenient for his Foxy subjects, but might cost him more money as well! As such, he'll consider () different values, . For each one, he'd like to know how many tax dollars would need to be spent to shut down all roads which lie on at least one sufficiently short path from city to city . Since you don't like Foxen either, you've agreed to help the Wolf write a program to calculate this!

#### Input Specification

The first line contains 4 integers, each separated by a space:

- (), the number of cities, followed by
- (), the number of roads, followed by
- (), the starting city, followed by
- (), the ending city.

Each of the next lines contain four space-separated integers , and describing the road from to with length and shutdown cost , where , .

The next line will contain (), the number of different distance values to consider.

The next lines each contain one integer () which is the distance value to consider in shutting down roads.

The following conditions hold for the input data:

- For test cases worth up to 20% of the points, ;
- For test cases worth up to 20% of the points, ;
- For test cases worth up to 80% of the points, .

#### Output Specification

The output consists of lines, each with one integer, representing the total cost required to shut down all necessary roads given a distance value of , for .

#### Sample Input 1

```
4 5 1 3
1 2 5 1
1 2 8 50
2 3 2 15
3 1 80 1000
3 4 1 1
4
8
6
90
94
```

#### Output for Sample Input 1

```
16
0
66
1066
```

#### Explanation of Output for Sample Input 1

The map of the country is illustrated below, with each road labelled with its length only:

If , the first and the third roads need to be shut down, as they're both part of a path from city to city of length . This incurs a total cost of .

If , no roads need to be shut down, as no paths from city to city with total length or less exist.

If , the first three roads all need to be shut down.

If , the fourth road must additionally be shut down, as it lies on a path from city to city of length exactly , consisting of the first, third, fourth, first and then third roads.

#### Sample Input 2

```
4 3 1 2
2 1 1 1
3 4 10000 10000
4 3 10000 10000
1
1000000000
```

#### Sample Output 2

`0`

#### Explanation 2

The map of the country is illustrated below:

As can be seen, the Foxen already have a problem, as no path from city to city exists! As such, for any value of , King Gruff doesn't need to shut down any roads.

## Comments