Submeter | Todas submissőes | Melhores | Voltar |
Problem hidden
AAC1 - Atul and Aastha Chronicles 1 |
Aastha and Atul got so into each other during their date that they forgot to keep track of time. Now for students of our college in-time is a very serious issue. If a girl fails to reach her hostel before the stipulated time she will land up in a huge amount of trouble. Aastha doesn't want to land up in trouble so she asks you for help. She will provide you a map with many possible routes to her hostel The map will be a in the form of a set of roads. Your task is to tell her the minimum possible time within which she can reach there. Assume that the time taken to cover each road is 1 unit. Node 1 denotes the starting point and Node n denotes her hostel.
Input
First line contains T. T test cases follow.
First line of each test case contains two space-separated integers N, M.
Each of the next M lines contains two space-separated integers X and Y, denoting that there is a road between X and Y.
Output
Print the answer to each test case in a new line.
Constraints:
1 ≤ T ≤ 10
1 ≤ N ≤ 10^4
1 ≤ M ≤ 10^5
1 ≤ X, Y ≤ N
Example
Input: 2 3 2 1 2 2 3 4 4 1 2 2 3 3 4 4 2 Output: 2 2
Adicionado por: | Dewang Sultania |
Data: | 2016-03-14 |
Tempo limite: | 3s |
Tamanho do fonte: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Linguagem permitida: | MAWK BC C NCSHARP CSHARP C++ 4.3.2 CPP CPP14 C99 COFFEE DART FORTH JAVA JS-RHINO JULIA KTLN OCT PHP PROLOG PYTHON PYPY PYPY3 PYTHON3 R RACKET SQLITE SWIFT UNLAMBDA |
Origem: | hackerearth-codemonk |