Breadth First Search#522

Breadth First Search

1 second
128 megabytes
Easy (≈1000)

Given an undirected graph. Find the shortest distance between two specified vertices.

Input

The first line contains three positive integers and f~(1 \le s, f \le n \le 100). Here, is the number of vertices in the graph, and are the initial and final vertices. The next lines provide the adjacency matrix of the graph. If the value at the -th element of the -th row is , there is an edge between vertex and vertex .

Output

Print the minimum distance from the initial vertex to the final vertex. If no path exists, print .

Examples

Example 1

Loading
Loading