Dijkstra Algorithm#1365

Dijkstra Algorithm

1 second
128 megabytes
Very easy

You are given a directed weighted graph. Find the shortest distance from vertex to vertex .

Input

The first line contains three integers , , and (1 \leq n \leq 100,\ 1 \leq s, f \leq n), where is the number of vertices in the graph. Each of the following lines contains integers, representing the adjacency matrix of the graph. The integer at the -th row and -th column indicates the weight of the edge from vertex to vertex . A value of means there is no edge between the vertices, while a non-negative value represents the weight of the edge. The main diagonal of the matrix always contains zeros.

Output

Print the shortest distance from vertex to vertex . If there is no path between the two vertices, print .

Examples

Example 1

Loading
Loading