Dijkstra#2351

Dijkstra

2 seconds
128 megabytes
Very easy

A directed, weighted graph is given. Find the shortest distance from vertex to vertex .

Input

The first line contains three integers , , and : 1 \leq n \leq 2000, 1 \leq s, f \leq n, where is the number of vertices, is the starting vertex, and is the target vertex. Each of the next lines contains integers: the adjacency matrix a_{i,j}, where means there is no edge from to , and any non-negative integer is the weight of the edge. The main diagonal contains zeros. Vertices are numbered from to .

Output

Print the shortest distance from to , or if no path exists.

Examples

Example 1

Loading
Loading