10665 - All Pair Shortest Path   

Description

Given a directed graph G by adjacency matrix

Find all pair shortest path. Print the answer by a matrix

Input

The first line is an integer T, the number of testcases

For each testcase:

The first line is n , there are n vertices {1,2,...,n}

Below is a matrix Gij denote the distance from vertex i to vertex j

1<=distance of an edge,n<=100

Output

For each testcase

print a matrix M such that Mij is the length of shortest path from i to j

Sample Input  Download

Sample Output  Download

Tags




Discuss