The shortest distance#4852

The shortest distance

2 seconds
128 megabytes
Very easy

The directed graph is given. Find the shortest distance from the vertex to other vertices of the graph.

Input

The first line contains two integers and x~(1 \le n \le 1000, 1 \le x \le n) — the number of vertices in a graph and the starting vertex. Each of the next lines contains numbers — the adjacency matrix of the graph: the -th line and -th column contains "", if the vertices and are connected with the edge, and "", if there is no edge between them. The main diagonal contains zeroes.

Output

Print the numbers d_1, d_2, \ldots, d_n, where d_i is if there is no path from to , or the minimal distance from to otherwise.

Examples

Example 1

Loading
Loading