EZDIJKST  Easy Dijkstra Problem
Determine the shortest path between the specified vertices in the graph given in the input data.
Hint: You can use Dijkstra's algorithm.
Hint 2: if you're a lazy C++ programmer, you can use set and cin/cout (with sync_with_stdio(0))  it should suffice.
Input
first line  one integer  number of test cases
For each test case the numbers V, K (number of vertices, number of edges) are given,
Then K lines follow, each containing the following numbers separated by a single space:
a_{i}, b_{i}, c_{i}
It means that the graph being described contains an edge from a_{i} to b_{i},
with a weight of c_{i}.
Below the graph description a line containing a pair of integers A, B is present.
The goal is to find the shortest path from vertex A to vertex B.
All numbers in the input data are integers in the range 0..10000.
Output
For each test case your program should output (in a separate line) a single number C  the length of the shortest path from vertex A to vertex B. In case there is no such path, your program should output a single word "NO" (without quotes)
Example
Input: 3 3 2 1 2 5 2 3 7 1 3 3 3 1 2 4 1 3 7 2 3 1 1 3 3 1 1 2 4 1 3 Output: 12 5 NO
hide comments
Rajat (1307086):
20150723 00:08:42
Direct problem. 

Aman Agarwal:
20150629 19:50:01
weak test cases :( 

SANDEEP KUMAR:
20150629 13:05:53
My god,was using scanf inside io_base::sync_with_stdio(FALSE),got 7 SIGSEV's and finally AC in 0.00s :) 

Shubham:
20150610 22:24:02
thanks to STL in c++...:) 

RAHUL:
20150525 16:19:35
my god this is directed


lovecode:
20150131 07:24:03
i was taking undirected graph this cause me 1 WA......PROBLEM SETTER plz mention this in question 

Shaurya Chaturvedi:
20150106 15:20:16
Thanks @tranquil, got WA: I used undirected. :P 

shiva:
20141213 20:54:55
http://ideone.com/JN0y7j


yagyank:
20141128 06:00:03
Breaking on loop from target node does not cost wa :) 

Neeraj :
20140929 22:04:07
Breaking from loop on finding target node costed me 4 WA's. Print result after all the distances are calculated. Still dont know the reason why ? 
Added by:  Robert Rychcicki 
Date:  20090110 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS OBJC PERL6 VB.NET 