시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 0 0 0 0.000%

문제

Da Vinci has a wide range of interests including botany. He once planned to travel around Florence to study plant domestication and ecosystem. There were n cities in Florence and city i had wi species of plants, while each of m bidirectional roads connected a pair of cities. It was possible to travel between every pair of cities via these paths.

Da Vinci started from city s and he could travel to one of the adjacent cities through one bidirectional road. However, if he traveled to some city v through road u → v, he would not immediately return to city u using the same road. (It was boring to travel back and forth on the same road!) Da Vinci wanted to see as many species of plants as possible – in other words, he hoped to maximize ∑City i is visited wi. He could repeatedly visit a city, but the number of species in that city would only count once. What is the maximum number of plant species he could see during the tour, assuming that he did not care about which city to end the trip?

입력

The first line is the number 1 ≤ K ≤ 20 of input data sets, followed by K data sets, each of the following form:

The first line are two integers 1 ≤ n, m ≤ 1000 separated by space. The second line has n integers 0 ≤ wi ≤ 106. Each of the following m lines contains two integers 1 ≤ xi, yi ≤ n, describing the j-th road connecting city xj and yj. The next line has a single integer s(1 ≤ s ≤ n) – the city da Vinci started with.

It is possible to travel between any pairs of cities using these roads, no two roads connect the same pair of cities, and no road connects a city to itself.

출력

For each data set, output “Data Set x:” on a line by itself, where x is its number. Then, output the maximum number of plant species da Vinci could see.

Each data set should be followed by a blank line.

예제 입력 1

2
4 3
1 2 3 4
1 2
1 3
1 4
2
5 7
2 2 8 6 9
1 2
1 3
2 4
3 2
4 5
2 5
1 5
2

예제 출력 1

Data Set 1:
7

Data Set 2:
27