Pondo Shortest Paths


You are given a connected undirected graph with nn vertices and mm weighted edges. For every pair of vertices, determine the shortest-path distance between them.

Input

The first line contains two space-separated integers nn and mm.

Each of the next mm lines contains three integers uu, vv, and ww, denoting an undirected edge between uu and vv with weight ww. There may be multiple edges between the same pair of vertices, and there may be self-loops.

Vertices are numbered 11 through nn.

Output

Print nn lines. The ithi^{th} line should contain nn space-separated integers ai,1,ai,2,…,ai,na_{i,1}, a_{i,2}, \ldots, a_{i,n}, where au,va_{u,v} is the shortest-path distance from uu to vv.

Constraints

  • 1≤n≤1001 \le n \le 100
  • 1≤m≤n⋅(n−1)21 \le m \le \frac{n \cdot (n - 1)}{2}
  • 1≤u,v≤n1 \le u, v \le n
  • 1≤w≤1001 \le w \le 100

Example 1

Input 1
4 5
1 2 5
1 3 9
2 3 1
4 2 3
3 4 2
Output 1
0 5 6 8
5 0 1 3
6 1 0 2
8 3 2 0

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.