Diameter of the graph#1796

Diameter of the graph

1 second
128 megabytes
Medium

You are given a connected undirected weighted graph.

The distance between two vertices is the length of the shortest path between them. The diameter of the graph is the maximum distance between any pair of its vertices. The eccentricity of a vertex is the maximum distance from to any other vertex of the graph. The radius of the graph is the minimum eccentricity over all its vertices.

Find the diameter and the radius of the graph.

Input

The first line contains the number of vertices n~(1 \le n \le 100). Each of the next lines contains integers — the adjacency matrix of the graph, where means that there is no edge between the corresponding vertices, and a non-negative integer means that there is an edge of the given weight. The main diagonal of the matrix always contains zeros, and the edge weights do not exceed .

Output

Print two integers: the diameter and the radius of the graph.

Examples

Example 1

Loading
Loading