eolymp
bolt
Try our new interface for solving problems

Path

In an undirected graph is required to find a minimal path between two vertices. \InputFile In the input file is written first, the number \textbf{N} - the number of vertices in the graph (\textbf{1} ≤ \textbf{N} ≤ \textbf{100}). Then write the adjacency matrix (\textbf{0} denotes the absence of ribs, \textbf{1} - presence of an edge). Then write the number two peaks - the start and end. \OutputFile The output display file \textbf{L} - length of the shortest path (number of edges that need to go). If the path does not exist, output a single number \textbf{-1}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2
0 1
1 0
1 2
Output example #1
1