XadillaX has chosen some elective courses.
Some courses have relation. For example:
Course A can be the pre-course of Course B, and you need to spend S spirit to transform Courese A to Course B. Opposite, B can be the pre-course either and he need to spend S spirit as well.
Now give you N courses and their relation. XadillaX choose a course to learn at first, and you should tell him the least spirit he have to spend to finish all the course.
You can consider that all the courses have relation either direct or not direct.
For each case, you should output the minimum spirit XadillaX will spend after finish all the course. If XadillaX can't transform to all the courses by learning the first course, you should output "No".
XadillaX takes class A at first. Let A be the pre-course when he takes B. And let A be the pre-course when
he takes C.