TRAFFICN - Traffic Network

The city traffic network consists of n nodes numbered from 1 to n and m one-way roads connecting pairs of nodes. In order to reduce the length of the shortest path between two different critical nodes s and t, a list of k two-way roads are proposed as candidates to be constructed.
Your task is to write a program to choose one two-way road from the proposed list in order to minimize the resulting shortest path between s and t.

Input

The input file consists of several data sets. The first line of the input file contains the number of data sets which is a positive integer and is not bigger than 20. The following lines describe the data sets.

Output

For each data set, write on one line the smallest possible length of the shortest path after building the chosen one two-way road from the proposed list. In case, there does not exist a path from s to t, write -1.

don't just blindly take 1061109567 , u can take any value greater than 200000000 because the maximum value of cost can reach 100000*1000 = 100000000 so to be on safe side take value greater than 200000000 , i took 300000000 and got ac!