
Mr. Malnar has finally reached his annual vacation.
The country he decided to travel to can be represented as cities and
bidirectional roads connecting them.
Each road has the same length, and it is possible to reach any city from any other by traveling on these roads.
A path from city
to city
is defined as a sequence of roads such that, starting from city
and sequentially traversing the roads in that sequence, one ends up in city
.
The length of a path is defined as the number of roads on that path.
Mr. Malnar routinely booked the most expensive hotel in one of the cities and then started to plan his journey. To facilitate his planning, he recorded the length of the shortest path needed from the hotel to each city.
Excited about his long-awaited vacation, Mr. Malnar completely forgot in which city the hotel is located. He certainly does not want to miss the trip, so he asks you to determine in which cities the hotel can be located.
Input Specification
In the first line, there are integers and
, the number of cities and the number of roads connecting them
.
In the -th of the following
lines, there are numbers
and
, indicating that there is a road between cities
and
.
There is at most one road between any two cities.
In the last line, there are integers, the
-th number
indicates the distance from the
-th city to the city where the hotel is located, or
-1
if Mr. Malnar did not record that distance .
Output Specification
In the first line, write the number of cities where the hotel can be located.
In the second line, write the labels of the cities where the hotel can be located, in ascending order.
Scoring
Subtask | Points | Constraints |
---|---|---|
1 | 10 | |
2 | 20 | |
3 | 35 | |
4 | 45 | No additional constraints. |
Sample Input 1
7 6
1 2
1 3
3 4
3 5
3 6
5 7
2 -1 -1 -1 -1 -1 3
Sample Output 1
2
4 6
Explanation for Sample 1
The path from the city labeled 4 to the city labeled 1 is of length , while the path from the city labeled 4
to the city labeled 7 is of length
. Therefore, city 4 satisfies both conditions and the hotel can be located
there.
The same holds true for the city labeled 6.
Sample Input 2
6 6
1 2
2 3
3 4
4 5
5 6
6 1
2 -1 -1 1 -1 -1
Sample Output 2
2
3 5
Sample Input 3
4 3
1 2
2 3
3 4
1 -1 -1 1
Sample Output 3
0
Comments