You are given a complete undirected graph. For each pair of vertices you are given the length of the edge that connects them. Find the shortest paths between each pair of vertices in the graph and return the length of the longest of them.

The first line of the input contains a single integer N (3 ≤ N ≤ 10). The following N lines each contain N space-separated integers. jth integer in ith line aij is the length of the edge that connects vertices i and j. aij = aji, aii = 0, 1 ≤ aij ≤ 100 for i ≠ j.

Output the maximum length of the shortest path between any pair of vertices in the graph.

NoteYou're running short of keywords, so you can't use some of them:definedoforforeachwhilerepeatuntilifthenelseelifelsifelseifcaseswitch

//made by kuailezhish
//gl && hf
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <stack>
#include <list>
#include <sstream>
#include <complex>
#include <cstring>
#include <ctime>

using namespace std;

#def\
ine FF fo\
r

int a[50][50];
int n;

int main() {
    cin >> n;
    FF(int i = 1; i <= n; i++) {
        FF(int j = 1; j <= n; j++) {
            cin >> a[i][j];
        }
    }

    FF(int k = 1; k <= n; k++) {
        FF(int i = 1; i <= n; i++) {
            FF(int j = 1; j <= n; j++) {
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
            }
        }
    }

    int ans = 0;
    FF(int i = 1; i <= n; i++) {
        FF(int j = 1; j <= n; j++) {
            ans = max(ans, a[i][j]);
        }
    }

    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const unsigned char N = (unsigned char) 10;

unsigned char n;
int x;
unsigned char mat[N][N];

inline unsigned char smin(const unsigned char& a, const unsigned char& b) { return a < b ? a : b; }
inline unsigned char smax(const unsigned char& a, const unsigned char& b) { return a > b ? a : b; }

inline unsigned char FOR3(const unsigned char& k, const unsigned char& i, const unsigned char& j) {
    mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR3(k, i, j + 1) : 0;
}

inline unsigned char FOR2(const unsigned char& i, const unsigned char& j) {
    FOR3(i, j, 0);
    return j + 1 < n ? FOR2(i, j + 1) : 0;
}

inline unsigned char FOR1(const unsigned char& i) {
    FOR2(i, 0);
    return i + 1 < n ? FOR1(i + 1) : 0;
}

inline unsigned char FOR_INPUT2(const unsigned char& i, const unsigned char& j) {
    cin >> x;
    mat[i][j] = x;
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

inline unsigned char FOR_INPUT1(const unsigned char& i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

inline unsigned char BILLY2(const unsigned char& i, const unsigned char& j) {
    return smax(mat[i][j], j + 1 < n ? BILLY2(i, j + 1) : 0);
}

inline unsigned char BILLY1(const unsigned char& i) {
    unsigned char ans = BILLY2(i, 0);
    unsigned char other = i + 1 < n ? BILLY1(i + 1) : 0;
    return smax(ans, other);
}

inline void solve() {
    cin >> x; n = x;
    FOR_INPUT1(0);
    FOR1(0);
    cout << (short) BILLY1(0) << endl;
}

int main() {
    solve();
    return 0;
}

#include<bits/stdc++.h>
#defin\
e rep fo\
r
#defin\
e rg i\
f
int n, map[15][15] ,ans;
int main() {
    scanf("%d", &n);
    rep (int i = 1; i <= n; i++)
        rep (int j = 1; j <= n; j++)
            scanf("%d", &map[i][j]);
    rep (int k = 1; k <= n; k++)
        rep (int i = 1; i <= n; i++)
            rep (int j = 1; j <= n; j++)
            	rg(map[i][k] + map[k][j] < map[i][j])
                    map[i][j] = map[i][k] + map[k][j];
    rep (int i = 1; i <= n; i++)
        rep (int j = 1; j <= n; j++)
        	rg(map[i][j] > ans)
        		ans = map[i][j];
    printf("%d\n", ans);
}

#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
int a[11][11],n;
int main()
{
	cin>>n;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
cin>>a[i][j];
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
int ans=-2e9;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	ans=max(ans,a[i][j]);
cout<<ans;
return 0;
}

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
int n,dis[20][20],maxn=0;
int R(int a,int b)
{
    return b<n?(scanf("%d",&dis[a][b]),R(a,b+1)):(a+1<n?R(a+1,0):1);
}
int Floyd(int i,int j,int k)
{
    return j<n?(dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]),Floyd(i,j+1,k)):(i+1<n?(Floyd(i+1,0,k)):(k+1<n?(Floyd(0,0,k+1)):1));
}
int M(int i,int j)
{
    return j<n?(maxn=max(maxn,dis[i][j]),M(i,j+1)):(i+1<n?(M(i+1,0)):1);
}
int main()
{
    scanf("%d",&n);
    R(0,0);
    Floyd(0,0,0);
    M(0,0);
    printf("%d\n",maxn);
    return 0;
}

#include <iostream>

using namespace std;

int n;
int a[10][10];

bool read(int i,int j)
{
	j!=n||((++i)&(j=0));
    i==n||((cin>>a[i][j])&&(read(i,j+1)));
}

bool recalc(int i,int j,int k)
{
	a[j][k]=a[j][k]>a[j][i]+a[i][k]?a[j][i]+a[i][k]:a[j][k];
}

bool floyd(int i,int j,int k)
{
	k!=n||((++j)&&(k=0));
	j!=n||((++i)&&(j=0));
	(i==n)||(recalc(i,j,k)&floyd(i,j,k+1));
}

int res=0;

bool getMax(int i,int j)
{
	j!=n||((++i)&(j=0));
    i==n||((res=res>a[i][j]?res:a[i][j])&(getMax(i,j+1)));
}

int main()
{
	cin>>n;
	int i=0;int j=0;
	j==n;
	read(0,0);
	floyd(0,0,0);
	getMax(0,0);
	cout<<res;
}

#include<bits/stdc++.h>
using namespace std;
int a[11][11],n;
int main()
{
	cin>>n;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
cin>>a[i][j];
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
int ans=-2e9;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	ans=max(ans,a[i][j]);
cout<<ans;
return 0;
}

#include <stdio.h>

int const MAXN = 16;

int d[MAXN][MAXN];
int n;
int ans = 0;

void read(int i, int j)
{
	scanf("%d", &d[i][j]);
	++ j;
	j == n ? (j = 0, ++i) : 0;
	i < n ? read(i, j) : 0;
}

void floyd(int i, int j, int k)
{
	int s = d[i][k] + d[k][j];
	s < d[i][j] ? d[i][j] = s : 0;
	++ j;
	j == n ? (j = 0, ++i) : 0;
	i == n ? (i = 0, ++k) : 0;
	k < n ? floyd(i, j, k) : 0;
}

void solve(int i, int j)
{
	ans = ans < d[i][j] ? d[i][j] : ans;
	++ j;
	j == n ? (j = 0, ++i) : 0;
	i < n ? solve(i, j) : 0;
}

int main()
{
	scanf("%d", &n);
	read(0, 0);
	floyd(0, 0, 0);
	solve(0, 0);
	printf("%d", ans);
	return 0;
}

#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 10;

int n;

int g[N][N];

int ans;

void (*f)(int, int, int);

void read(int i, int j, int k) {
	scanf("%d", &g[i][j]);
}

void floyd(int k, int i, int j) {
	g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}

void maxs(int i, int j, int k) {
	i == j ? 0 : ans = max(ans, g[i][j]);
}

void loop1(int i, int n, int j, int m, int k, int l);

int loop0(int i, int n, int j, int m, int k, int l) {
	f(i, j, k);
	loop1(i, n, j, m, k + 1, l);
	return 0;
}

void loop1(int i, int n, int j, int m, int k, int l) {
	k == l ? ++j, k = 0 : 0;
	j == m ? ++i, j = 0 : 0;
	i == n ? 0 : loop0(i, n, j, m, k, l);
}

int main() {
	scanf("%d", &n);
	f = &read;
	loop1(0, n, 0, n, 0, 1);
	f = &floyd;
	loop1(0, n, 0, n, 0, n);
	f = &maxs;
	loop1(0, n, 0, n, 0, 1);
	printf("%d\n", ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int g[11][11];
int n;
int ans = 0;

int _w(int i, int j, int k);

int war(int i, int j, int k){
    return (i == n) ? 1 : k == n ? war(i, j+1, 0) : j == n ? war(i+1, 0, 0) : _w(i,j,k);
}

int _r(int i, int j);

int readg(int i, int j){
    return i == n ? 1 : j == n ? readg(i+1, 0) : _r(i,j);
}

int t = 0;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    readg(0, 0);
    war(0,0,0);
    t = 1;
    war(0,0,0);
    cout << ans;
    return 0;
}

int _w(int i, int j, int k){
    g[j][k] = min(g[j][i] + g[i][k], g[j][k]);
    ans = t? max(ans, g[j][k]) : 0;
    war(i, j, k+1);
}

int _r(int i, int j){
    cin >> g[i][j];
    readg(i, j+1);
}

#include<algorithm>
#include<cstdio>
using namespace std;
const int N=12;
int n,ans=-1e9,dis[N][N];
int main(){
scanf("%d",&n);
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)
scanf("%d",&dis[i][j]);
f\
o\
r(int k=1;k<=n;++k)
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)
dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)
ans=max(ans,dis[i][j]);
printf("%d\n",ans);
return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstring>
#include <deque>
#include <stack>
#include <stdio.h>
#include <map>
#include <set>
#include <time.h>
#include <string>
#include <fstream>
#include <queue>
#include <bitset>
#include <cstdlib>
typedef long long ll;
typedef long double ld;
using namespace std;
ll i,j,n, m,l,r,k, q, x,y, mx, cur, INF;
ll d[1005][1005], b[100500];
string s;
ll lalkaij()
{
	cin >> d[i][j];
	j++;
	i = (j==n?i+1:i);
	j = (j==n?0:j);
	return i==n?0:lalkaij();
}

ll lalkaijk()
{
	d[i][j] = (d[i][k] < INF && d[k][j] < INF)?min(d[i][j], d[i][k] + d[k][j]):d[i][j];
	j++;
	i = (j==n?i+1:i);
	j = (j==n?0:j);
	k = (i==n?k+1:k);
	i = (i==n?0:i);
	return k==n?0:lalkaijk();
}
ll lalkaij2()
{
	q = max(q, d[i][j]);
	j++;
	i = (j==n?i+1:i);
	j = (j==n?0:j);
	return i==n?0:lalkaij2();
}
int main()
{
	//freopen("input.txt","r",stdin);
	INF = (ll)1e+9;
	cin >> n;
	lalkaij();
	i=j=k=0;
	lalkaijk();
	i=j=0;
	lalkaij2();
	cout << q << endl;
	return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;
int E[20][20];
int main()
{
int n,ans=0;
s\
canf("%d",&n);
f\
o\
r (register int i=1;i<=n;++i)
f\
o\
r (register int j=1;j<=n;++j) s\
canf("%d",&E[i][j]);
f\
o\
r (int k=1;k<=n;++k)
f\
o\
r (int i=1;i<=n;++i)
f\
o\
r (int j=1;j<=n;++j)
E[i][j]=min(E[i][j],E[i][k]+E[k][j]);
f\
o\
r (int i=1;i<=n;++i)
f\
o\
r (int j=1;j<=n;++j)
ans=max(ans,E[i][j]);
printf("%d",ans);
return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iterator>
#include <cstring>
using namespace std;

int read_one(int n, vector<vector<int>>& a, int r, int c) {
	cin >> a[r][c];
	return 0;
}

int read_row(int n, vector<vector<int>>& a, int r) {
	n > 0 ? read_one(n, a, r, 0) : 0;
	n > 1 ? read_one(n, a, r, 1) : 0;
	n > 2 ? read_one(n, a, r, 2) : 0;
	n > 3 ? read_one(n, a, r, 3) : 0;
	n > 4 ? read_one(n, a, r, 4) : 0;
	n > 5 ? read_one(n, a, r, 5) : 0;
	n > 6 ? read_one(n, a, r, 6) : 0;
	n > 7 ? read_one(n, a, r, 7) : 0;
	n > 8 ? read_one(n, a, r, 8) : 0;
	n > 9 ? read_one(n, a, r, 9) : 0;

	return 0;
}

int read_all(int n, vector<vector<int>>& a) {
	n > 0 ? read_row(n, a, 0) : 0;
	n > 1 ? read_row(n, a, 1) : 0;
	n > 2 ? read_row(n, a, 2) : 0;
	n > 3 ? read_row(n, a, 3) : 0;
	n > 4 ? read_row(n, a, 4) : 0;
	n > 5 ? read_row(n, a, 5) : 0;
	n > 6 ? read_row(n, a, 6) : 0;
	n > 7 ? read_row(n, a, 7) : 0;
	n > 8 ? read_row(n, a, 8) : 0;
	n > 9 ? read_row(n, a, 9) : 0;

	return 0;
}

int fw_loop4(int n, vector<vector<int>>& a, int k, int i, int j) {
	a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
	return 0;
}

int fw_loop3(int n, vector<vector<int>>& a, int k, int i) {
	n > 0 ? fw_loop4(n, a, k, i, 0) : 0;
	n > 1 ? fw_loop4(n, a, k, i, 1) : 0;
	n > 2 ? fw_loop4(n, a, k, i, 2) : 0;
	n > 3 ? fw_loop4(n, a, k, i, 3) : 0;
	n > 4 ? fw_loop4(n, a, k, i, 4) : 0;
	n > 5 ? fw_loop4(n, a, k, i, 5) : 0;
	n > 6 ? fw_loop4(n, a, k, i, 6) : 0;
	n > 7 ? fw_loop4(n, a, k, i, 7) : 0;
	n > 8 ? fw_loop4(n, a, k, i, 8) : 0;
	n > 9 ? fw_loop4(n, a, k, i, 9) : 0;

	return 0;
}

int fw_loop2(int n, vector<vector<int>>& a, int k) {
	n > 0 ? fw_loop3(n, a, k, 0) : 0;
	n > 1 ? fw_loop3(n, a, k, 1) : 0;
	n > 2 ? fw_loop3(n, a, k, 2) : 0;
	n > 3 ? fw_loop3(n, a, k, 3) : 0;
	n > 4 ? fw_loop3(n, a, k, 4) : 0;
	n > 5 ? fw_loop3(n, a, k, 5) : 0;
	n > 6 ? fw_loop3(n, a, k, 6) : 0;
	n > 7 ? fw_loop3(n, a, k, 7) : 0;
	n > 8 ? fw_loop3(n, a, k, 8) : 0;
	n > 9 ? fw_loop3(n, a, k, 9) : 0;

	return 0;
}

int fw_loop1(int n, vector<vector<int>>& a) {
	n > 0 ? fw_loop2(n, a, 0) : 0;
	n > 1 ? fw_loop2(n, a, 1) : 0;
	n > 2 ? fw_loop2(n, a, 2) : 0;
	n > 3 ? fw_loop2(n, a, 3) : 0;
	n > 4 ? fw_loop2(n, a, 4) : 0;
	n > 5 ? fw_loop2(n, a, 5) : 0;
	n > 6 ? fw_loop2(n, a, 6) : 0;
	n > 7 ? fw_loop2(n, a, 7) : 0;
	n > 8 ? fw_loop2(n, a, 8) : 0;
	n > 9 ? fw_loop2(n, a, 9) : 0;

	return 0;
}

int sol(int n, vector<vector<int>>& a) {
	int sol = 0;
	sol = max(sol, n > 0 ? *max_element(a[0].begin(), a[0].end()) : 0);
	sol = max(sol, n > 1 ? *max_element(a[1].begin(), a[1].end()) : 0);
	sol = max(sol, n > 2 ? *max_element(a[2].begin(), a[2].end()) : 0);
	sol = max(sol, n > 3 ? *max_element(a[3].begin(), a[3].end()) : 0);
	sol = max(sol, n > 4 ? *max_element(a[4].begin(), a[4].end()) : 0);
	sol = max(sol, n > 5 ? *max_element(a[5].begin(), a[5].end()) : 0);
	sol = max(sol, n > 6 ? *max_element(a[6].begin(), a[6].end()) : 0);
	sol = max(sol, n > 7 ? *max_element(a[7].begin(), a[7].end()) : 0);
	sol = max(sol, n > 8 ? *max_element(a[8].begin(), a[8].end()) : 0);
	sol = max(sol, n > 9 ? *max_element(a[9].begin(), a[9].end()) : 0);
	return sol;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	int n, i, j;
	vector<vector<int>> a;

	cin >> n;
	a.resize(n, vector<int>(n, 0));

	read_all(n, a);
	fw_loop1(n, a);
	cout << sol(n, a);
}

#include <bits/stdc++.h>

using namespace std;

const int N = (int) 10;

int n;
int mat[N][N];

int FOR3(const int& k, const int& i, const int& j) {
    mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR3(k, i, j + 1) : 0;
}

int FOR2(const int& i, const int& j) {
    FOR3(i, j, 0);
    return j + 1 < n ? FOR2(i, j + 1) : 0;
}

int FOR1(const int& i) {
    FOR2(i, 0);
    return i + 1 < n ? FOR1(i + 1) : 0;
}

int FOR_INPUT2(const int& i, const int& j) {
    cin >> mat[i][j];
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

int FOR_INPUT1(const int& i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

int BILLY2(const int& i, const int& j) {
    int ans = mat[i][j];
    int other = j + 1 < n ? BILLY2(i, j + 1) : 0;
    return max(ans, other);
}

int BILLY1(const int& i) {
    int ans = BILLY2(i, 0);
    int other = i + 1 < n ? BILLY1(i + 1) : 0;
    return max(ans, other);
}

void solve() {
    cin >> n;
    FOR_INPUT1(0);
    FOR1(0);
    cout << BILLY1(0) << endl;
}

int main() {
    solve();
    return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int map[1000][1000];
int nn,n;
void in(){
    cin>>map[nn/n][nn%n];
    nn++;
}

void out();
void xun1();
void xun2();
void xun3();
void xun4();
int ans = 0;
void (*ff1[])(){
    xun2,out
};
void (*ff2[])(){
    xun3,
    xun1
};
void (*ff3[])(){
    xun4,
    xun2
};
void out3(){
    cout<<ans<<endl;
    exit(0);
}
void (*ff5[])(){
    xun4,
    out
};
int x5 = -1;
int x1 = -1 , x2, x3;
void out2(){
    ddd:
    x2++;
    ans = max(ans,map[x5][x2]);
    (*ff5[x2/n])();
    goto ddd;
}

void (*ff4[])(){
    out2,
    out3
};

void out(){

    ccc:
    x5++;
    x2 = -1;
    (*ff4[x5/n])();
    goto ccc;
}

void xun1(){
    xu1:
    x1++;
    x2 = -1;
    (*ff1[x1/n])();
    goto xu1;
}
void xun2(){
    xu2:
    x2++;
    x3 = -1;
    (*ff2[x2/n])();
    goto xu2;
}
void xun3(){
    xu3:
    x3++;
    map[x3][x2] = map[x2][x3] = min(map[x2][x1]+map[x1][x3],map[x2][x3]);
    (*ff3[x3/n])();
    goto xu3;
}
void xun4(){
}

void (*f[])()={
    in,
    xun1
};
int main(){

    cin>>n;
    nn = 0;
    aaa:;
    (*f[nn/(n*n)])();
    goto aaa;
}

#include <iostream>

using namespace std;

int A[30][30];
int N;

int ANS = 0;

bool readLine(int U,int x){
    clog <<U<<" "<<x<<endl;
    cin >> A[U][x];
    x++;
    return (x!=N)  && readLine(U,x);
}

bool read(int U){
    readLine(U,0);
    U++;
    return (U!=N)  && read(U);
}

bool ffri(int i, int j, int k){
    clog <<i<<" "<<j<<" "<<k<<endl;
    A[j][k] = min(A[j][k], A[j][i] + A[i][k]);
    k++;
    return  (k!=N) && ffri(i,j,k);
}

bool ffri(int i, int j){
    ffri(i,j,0);
    j++;
    return  (j!=N) && ffri(i,j);
}

bool ffri(int i){
    ffri(i,0);
    i++;
    return  (i!=N) && ffri(i);
}

bool Ffri(int i, int j){
    //clog << i <<" "<<j<<endl;
    ANS = max(ANS, A[i][j]);
    j++;
    return  (j!=N) && Ffri(i,j);
}

bool Ffri(int i){
    Ffri(i,i+1);
    i++;
    return  (i!=N-1) && Ffri(i);
}

int main(){
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    read(0);

    ffri(0);

    Ffri(0);
    cout << ANS;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#def\
ine CAT(a,b) a##b

#def\
ine F CAT(fo,r)

int a[10][10];

int main(){
	int n;
	scanf("%d",&n);
        F(int i = 0; i < n; ++i){
            F(int j = 0; j < n; ++j){
                cin >> a[i][j];
            }
        }

        F(int k = 0; k < n; ++k){
            F(int i = 0; i < n; ++i){
                F(int j = 0; j < n; ++j){
                    a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
                }
            }
        }

        int ans = 0;
        F(int i = 0; i < n; ++i){
            F(int j = 0; j < n; ++j){
                ans = max(ans, a[i][j]);
            }
        }
        printf("%d\n",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,a[15][15],mx=INT_MIN;
int main()
{
cin>>n;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
cin>>a[i][j];
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
a[i][j]=min(a[i][k]+a[k][j],a[i][j]);
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
mx=max(mx,a[i][j]);
cout<<mx;
}

#include <bits/stdc++.h>
using namespace std;
#defin\
e rep(i, x, y) fo\
r (int i = x;i <= y;i ++)
int n, dp[15][15];
int main()
{
    cin >> n;
    rep(i, 1, n)
    {
    	rep(j, 1, n)
    	{
    		cin >> dp[i][j];
        }
    }
    int ans = -1;
    rep(k, 1, n)
    {
        rep(i, 1, n)
        {
            rep(j, 1, n)
            {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    rep(i, 1,n)
    {
        rep(j, 1, n)
        {
            ans = max(dp[i][j], ans);
        }
    }
    cout << ans
;}

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int a[20][20], n, ans;

int NEXT1(int x)
{
    cin >> a[x/n][x%n];
    return (x == n * n) ? 0 : NEXT1(x+1);
}

int NEXT2(int x)
{
    int k = x / (n * n);
    int i = ((x % (n * n)) / n);
    int j = x % n;
    a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
    return (x == n * n * n) ? 0 : NEXT2(x+1);
}

int NEXT3(int x)
{
    ans = max(ans, a[x/n][x%n]);
    return (x == n * n) ? 0 : NEXT3(x+1);
}

int main()
{
   // freopen("inp.txt", "r", stdin); freopen("out.txt", "w", stdout);
    cin >> n;
    NEXT1(0);
    NEXT2(0);
    NEXT3(0);
    cout << ans;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int g[50][50];
int n;

int read ( int i, int j ) {
  return ( i == n ) ? 0 : (
    ( cin >> g[i][j] ), read ( i + (j+1)/n, (j+1)%n ) );
}

int floyd ( int i, int j, int k ) {
  return i == n ? 0 : (
    g[j][k] = min ( g[j][k], g[j][i] + g[i][k] ),
    k++,
    j += k/n, k%= n,
    i += j/n, j%= n,
    floyd ( i, j, k ) );
}

int solve ( int i, int j ) {
  return i == n ? 0: max ( g[i][j], solve ( i + (j+1)/n, (j+1)%n ) );
}

int main()
{
  cin >> n;
  read(0,0);
  floyd(0,0,0);
  cout << solve(0,0) << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[100][100],n,ans;
int main()
{
cin>>n;
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)cin>>a[i][j];
f\
o\
r(int k=1;k<=n;++k)
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j) a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)ans=max(ans,a[i][j]);
cout<<ans<<endl;
return 0;
}

#include <cstdio>
#include <string>
#include<cmath>
#include<iostream>
using namespace std;
#defin\
e f fo\
r
#defin\
e M 105
#defin\
e INF 0x3f3f3f3f

int map[M][M], dis[M], n, m,tmp;

int min(int a, int b){
    return a<b?a:b;
}

void floyd(){
    int i, j, k;
    f(k = 1; k <= n; k ++)
    	f(i = 1; i <= n; i ++)
        	f(j = 1; j <= n; j ++)
            	map[i][j] = min(map[i][j], map[i][k]+map[k][j]);
}
int main(){
   cin>>n;
        int i, j, a, b, c;
        f(i = 1; i <= n; i ++){
            f(j = 1; j <= n; j ++){
            	cin>>tmp;
            	map[i][j]=tmp==0?INF:tmp;
			}
        }
        floyd();
        int x=0;
        f(int i=1;i<=n;i++){
        	f(int j=i+1;j<=n;j++){
				x=x<map[i][j]?map[i][j]:x;
			}

		}
		cout<<x<<endl;

    return 0;
}

#include <bits/stdc++.h>
using ll = long long;

using namespace std;

const int N = 11;
int n;

struct Node {
	int i;
	ll dist;
	int prev;
	int adj[N];

	Node() : dist(LLONG_MAX), prev(-1) { }
};

vector<Node> nodes;

struct NodeCmp {
	bool operator()(const Node& a, const Node& b) {
		return a.dist > b.dist;
	}
};

using NodeQueue = priority_queue<Node, vector<Node>, NodeCmp>;

bool workNeighbour(NodeQueue& nq, Node& v, vector<Node>& nodes, int i) {
	nodes[i].dist = v.dist + v.adj[i];
	nodes[i].prev = v.i;
	nq.push(nodes[i]);
	return true;
}

bool workNode(NodeQueue& nq, Node& v, vector<Node>& nodes, int i) {
	bool tmp = (v.adj[i] && v.dist + v.adj[i] < nodes[i].dist) ? workNeighbour(nq, v, nodes, i) : true;
	return i == n-1 ? true : workNode(nq, v, nodes, i+1);
}

bool workQueue(NodeQueue& nq, vector<Node>& nodes) {
	auto v = nq.top();

	workNode(nq, v, nodes, 0);

	nq.pop();
	return nq.empty() ? true : workQueue(nq, nodes);
}

vector<Node> dijkstra(int from) {
	vector<Node> copy = nodes;
	copy[from].dist = 0;

	NodeQueue Q;
	Q.push(copy[from]);

	workQueue(Q, copy);

	return copy;
}

bool readDist(int i, int j) {
	scanf("%d", &nodes[i].adj[j]);
	return j == n-1 ? true : readDist(i, j+1);
}

bool readNode(int i) {
	nodes.emplace_back();
	nodes.back().i = i;
	readDist(i, 0);
	return i == n-1 ? true : readNode(i+1);
}

template<typename F>
bool range(int i, int j, F f) {
	f(i);
	return i == j-1 ? true : range(i + 1, j, std::forward<F>(f));
}

int main() {
	cin >> n;

	readNode(0);

	ll ret = 0;
	range(0, n, [&](int i) {
		auto info = dijkstra(i);
		range(0, n, [&](int j) {
			ret = max(ret, info[j].dist);
		});
	});

	cout << ret << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[100][100],n,ans;
int main()
{
cin>>n;
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)cin>>a[i][j];
f\
o\
r(int k=1;k<=n;++k)
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j) a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)ans=max(ans,a[i][j]);
cout<<ans;
}

#include <bits/stdc++.h>

using namespace std;

const unsigned char N = (unsigned char) 10;

unsigned char n;
int x;
unsigned char mat[N][N];

inline unsigned char smin(unsigned char a, unsigned char b) { return a < b ? a : b; }
inline unsigned char smax(unsigned char a, unsigned char b) { return a > b ? a : b; }

inline unsigned char FOR3(const unsigned char& k, const unsigned char& i, const unsigned char& j) {
    mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR3(k, i, j + 1) : 0;
}

inline unsigned char FOR2(const unsigned char& i, const unsigned char& j) {
    FOR3(i, j, 0);
    return j + 1 < n ? FOR2(i, j + 1) : 0;
}

inline unsigned char FOR1(const unsigned char& i) {
    FOR2(i, 0);
    return i + 1 < n ? FOR1(i + 1) : 0;
}

inline unsigned char FOR_INPUT2(const unsigned char& i, const unsigned char& j) {
    cin >> x;
    mat[i][j] = x;
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

inline unsigned char FOR_INPUT1(const unsigned char& i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

inline unsigned char BILLY2(const unsigned char& i, const unsigned char& j) {
    unsigned char ans = mat[i][j];
    unsigned char other = j + 1 < n ? BILLY2(i, j + 1) : 0;
    return smax(ans, other);
}

inline unsigned char BILLY1(const unsigned char& i) {
    unsigned char ans = BILLY2(i, 0);
    unsigned char other = i + 1 < n ? BILLY1(i + 1) : 0;
    return smax(ans, other);
}

inline void solve() {
    cin >> x; n = x;
    FOR_INPUT1(0);
    FOR1(0);
    cout << (int) BILLY1(0) << endl;
}

int main() {
    solve();
    return 0;
}

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#defin\
e rep fo\
r

using namespace std;

const int INF = 0x3f3f3f3f, MAXN = 15;
int n, map[MAXN][MAXN];
int main() {
    scanf("%d", &n);
    rep (int i = 1; i <= n; i++)
        rep (int j = 1; j <= n; j++)
            scanf("%d", &map[i][j]);
    rep (int k = 1; k <= n; k++)
        rep (int i = 1; i <= n; i++)
            rep (int j = 1; j <= n; j++)
                map[i][j] = min(map[i][j], map[i][k] + map[k][j]);//Floyd
    int ans = -INF;
    rep (int i = 1; i <= n; i++)
        rep (int j = 1; j <= n; j++)
            ans = max(ans, map[i][j]);
    printf("%d\n", ans);
}

#include<stdio.h>
int a[12][12],ans=-1;
int mn(int x,int y)
{
	return x<y?x:y;
}
int mx(int x,int y)
{
	return x>y?x:y;
}
int main()
{
	int n;
	scanf("%d",&n);
f\
o\
r(int i=1;i<=n;i++){
f\
o\
r(int j=1;j<=n;j++){
			scanf("%d",&a[i][j]);
		}
	}
f\
o\
r(int k=1;k<=n;k++){
f\
o\
r(int i=1;i<=n;i++){
f\
o\
r(int j=1;j<=n;j++){
				a[i][j]=mn(a[i][j],a[i][k]+a[k][j]);
			}
		}
	}
f\
o\
r(int i=1;i<=n;i++){
f\
o\
r(int j=1;j<=n;j++){
			ans=mx(ans,a[i][j]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include <iostream>
#include <vector>
using namespace std;
#def\
ine f0r fo\
r
int main(int argc, char **argv)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);
    int N;
    cin >> N;
    vector<vector<int> > a(N, vector<int> (N));
    f0r(int i = 0; i < N; i++){
        f0r(int j = 0; j < N; j++){
            cin >> a[i][j];
        }
    }
    int INF = 100 + 1;
    vector<vector<int> > dist(N, vector<int>(N, INF));
    f0r(int i = 0; i < N; i++){
        f0r(int j = 0; j < N; j++){
            dist[i][j] = a[i][j];
        }
    }
    f0r(int k = 0; k < N; k++){
        f0r(int i = 0; i < N; i++){
            f0r(int j = 0; j < N; j++){
                //+ <= INF + INF <= 202
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    int res = 0;
    f0r(int i = 0; i < N; i++){
        f0r(int j = 0; j < N; j++){
            res = max(res, dist[i][j]);
        }
    }
    //forr
    cout << res << endl;
    return 0;
}

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int E[20][20];
int main()
{
int n,ans=0;
scanf("%d",&n);
f\
o\
r (int i=1;i<=n;++i)
f\
o\
r (int j=1;j<=n;++j) s\
canf("%d",&E[i][j]);
f\
o\
r (int k=1;k<=n;++k)
f\
o\
r (int i=1;i<=n;++i)
f\
o\
r (int j=1;j<=n;++j)
E[i][j]=min(E[i][j],E[i][k]+E[k][j]);
f\
o\
r (int i=1;i<=n;++i)
f\
o\
r (int j=1;j<=n;++j)
ans=max(ans,E[i][j]);
printf("%d",ans);
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,f[15][15],ans;
int main(){
scanf("%d",&n);
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
scanf("%d",&f[i][j]);
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
ans=max(ans,f[i][j]);
printf("%d",ans);
return 0;
}//

#include <iostream>
#include <cmath>
using namespace std;
int n;
int map[100][100];
int ans;
int ii(int i, int j)
{
	cin >> map[i][j];
	((i == n && j == n) ? 0: ((j == n)? ii(i + 1, 1): ii(i, j + 1)));
}
int floyd(int i, int j, int k)
{
	map[j][k] = min(map[j][i] + map[i][k], map[j][k]);
	((i == n && j == n && k == n) ? 0: ((j == n && k == n)? floyd(i + 1, 1, 1): ((k == n)? floyd(i, j + 1, 1): floyd(i, j, k + 1))));
}
int ij(int i, int j)
{
	ans = max(ans, map[i][j]);
	((i == n && j == n) ? 0: ((j == n)? ij(i + 1, 1): ij(i, j + 1)));
}
int main()
{
	cin >> n;
	ii(1, 1);
	floyd(1, 1, 1);
	ij(1, 1);
	cout << ans;
}

#include <bits/stdc++.h>

using namespace std;

int sol, n, a[15][15];

int read(int x) {
    int i = x / n;
    int j = x % n;
    scanf("%d", &a[i][j]);
    return (x + 1 >= n * n) ? 0 : read(x + 1);
}

int go(int x) {
    int k = x / (n * n);
    int i = (x / n) % n;
    int j = x % n;
    a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
    return (x + 1 >= n * n * n) ? 0 : go(x + 1);
}

int find(int x) {
    int i = x / n;
    int j = x % n;
    sol = max(sol, a[i][j]);
    return (x + 1 >= n * n) ? 0 : find(x + 1);
}

int main() {
    cin.sync_with_stdio(false);

    scanf("%d", &n);

    read(0);
    go(0);
    find(0);

    printf("%d\n", sol);

    return 0;
}

#include<bits/stdc++.h>
#defi\
ne REP(i,a,b) fo\
r(int i=a;i<=b;i++)
using namespace std;

int M[11][11]={0};

int main(){
	int n;
	cin>>n;
	REP(i,1,n)REP(j,1,n)cin>>M[i][j];
	REP(k,1,n)REP(i,1,n)REP(j,1,n)M[i][j]=min(M[i][j],M[i][k]+M[k][j]);
	int ans=0;
	REP(i,1,n)REP(j,1,n)ans=max(ans,M[i][j]);
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
#defi\
ne lp(i,n) fo\
r(int i=0;i<n;i++)
using namespace std;

int main(){
    int n, cnt(0);
	cin >> n;
	int arr[n][n];
	lp(i, n)
		lp(j, n)
		cin >> arr[i][j];
	lp(i, n)
		lp(j, n)
			lp(k, n)
				arr[j][k] = min(arr[j][k], arr[j][i] + arr[i][k]);
	lp(i, n)
		lp(j, n)
			cnt = max(cnt, arr[i][j]);
	cout << cnt << endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

long long sm[100][100], ans = 0LL;

int n;
int cnt = 0;

int rec_read(int);

int f(int v) {
	cin >> sm[cnt/n][cnt%n];
	cnt++;
	return rec_read(v-1);
}

int rec_read(int v) {
	return (v <= 0) ? (0) : (f(v));
}

int rec_1(int);

int rec_2(int , int );

int rec_3(int , int , int );

int f_3(int i, int j, int k) {
	sm[j][k] = min(sm[j][k], sm[j][i] + sm[i][k]);
	return rec_3(i,j,k+1);
}

int rec_3(int i, int j, int k) {
	return (k >= n) ? (0) : (f_3(i,j,k));
}

int f_2(int a, int b) {
	int q = rec_3(a,b,0);
	return q + rec_2(a,b+1);
}

int rec_2(int a, int b) {
	return (b >= n) ? (0) : (f_2(a,b));
}

int f_1(int v) {
	int qq = rec_2(v, 0);
	return qq + rec_1(v+1);
}

int rec_1(int v) {
	return (v >= n) ? (0) : (f_1(v));
}

int rec_11(int);

int rec_22(int , int );

int f_22(int a, int b) {
	ans = max(ans, sm[a][b]);
	return 1 + rec_22(a,b+1);
}

int rec_22(int a, int b) {
	return (b >= n) ? (0) : (f_22(a,b));
}

int f_11(int v) {
	int qq = rec_22(v, 0);
	return qq + rec_11(v+1);
}

int rec_11(int v) {
	return (v >= n) ? (0) : (f_11(v));
}

int main() {
	cin>>n;
	rec_read(n*n);

	int qqq = rec_1(0);
	int eee = rec_11(0);

	(qqq + eee + n > 0) ? (cout<<ans, 1) : (0);
	return 0;
}

# include <iostream>

using namespace std;

int n;
int a[12][12];

int ck, cx, cy;

int ans = 0;

int frx (int idx);
int fry (int idx);
int prx (int idx);
int pry (int idx);
int sfrk (int idx);
int sfrx (int idx);
int sfry (int idx);

int frx (int idx)
{
	cx = idx;
	fry (1);
	return (idx < n) ? frx (idx + 1) : 0;
}

int fry (int idx)
{
	cy = idx;
	cin >> a[cx][cy];
	return (idx < n) ? fry (idx + 1) : 0;
}

int prx (int idx)
{
	cx = idx;
	pry (1);
	return (idx < n) ? prx (idx + 1) : 0;
}

int pry (int idx)
{
	cy = idx;
	ans = (ans < a[cx][cy]) ? a[cx][cy] : ans;
	return (idx < n) ? pry (idx + 1) : 0;
}

int sfrk (int idx)
{
	ck = idx;
	sfrx (1);
	return (idx < n) ? sfrk (idx + 1) : 0;
}

int sfrx (int idx)
{
	cx = idx;
	sfry (1);
	return (idx < n) ? sfrx (idx + 1) : 0;
}

int sfry (int idx)
{
	cy = idx;
	a[cx][cy] = (a[cx][cy] > a[cx][ck] + a[ck][cy]) ? a[cx][ck] + a[ck][cy] : a[cx][cy];
	return (idx < n) ? sfry (idx + 1) : 0;
}

int main ()
{
	cin >> n;
	frx (1);
	sfrk (1);
	prx (1);
	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[11][11],n;
int main()
{
	cin>>n;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
cin>>a[i][j];
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
int ans=-2e9;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	ans=max(ans,a[i][j]);
cout<<ans;
return 0;
}

#include <iostream>

using namespace std;

int G[110][110];
int INF = 1000*1000;
int n;
int MAX = 0;

int frloop(int i,void (*func)(int))
{
	func(i);
	return i==n?0:frloop(i+1,func);
}

int frloop(int i,int j,void (*func)(int,int))
{
	func(i,j);
	return j==n?0:frloop(i,j+1,func);
}

int frloop(int i,int j,int k,void (*func)(int,int,int))
{
	func(i,j,k);
	return k==n?0:frloop(i,j,k+1,func);
}

void assigninf(int i,int j)
{
	G[i][j]=INF;
}

void assignzero(int i)
{
	G[i][i]=0;
}

void assigninffunc(int i)
{
	frloop(i,0,assigninf);
}

void cinnum(int i,int j)
{
	cin>>G[i][j];
}

void cinfunc(int i)
{
	frloop(i,0,cinnum);
}

void maxl3(int k,int i,int j)
{
	G[i][j]=(G[i][j]>G[i][k]+G[k][j])?(G[i][k]+G[k][j]):G[i][j];
}
void maxl2(int i,int j)
{
	frloop(i,j,0,maxl3);
}
void maxl1(int i)
{
	frloop(i,0,maxl2);
}

void mxl2(int i,int j)
{
	MAX = G[i][j]>MAX?G[i][j]:MAX;
}
void mxl1(int i)
{
	frloop(i,0,mxl2);
}

int main()
{
	cin>>n;n--;

	frloop(0,assigninffunc);
	frloop(0,assignzero);

	frloop(0,cinfunc);

	frloop(0,maxl1);

	frloop(0,mxl1);

	cout<<MAX<<endl;
}

#include<iostream>
#defin\
e rep fo\
r
using namespace std;
int i,j,k,ans,n,a[15][15];
int main(){
	cin>>n;ans=0;
	rep(i=1;i<=n;i++)
		rep(j=1;j<=n;j++)cin>>a[i][j];
	rep(k=1;k<=n;k++)
		rep(i=1;i<=n;i++)
			rep(j=1;j<=n;j++)a[i][j]=min(a[i][k]+a[k][j],a[i][j]);
	rep(i=1;i<=n;i++)
		rep(j=i+1;j<=n;j++)ans=max(ans,a[i][j]);
	cout<<ans<<endl;
	return 0;
}

#include <iostream>
#include <algorithm>

#ifdef iamstupid
#endif

#def\
ine REP(I, N) fo\
r (int I = 0; I < N; ++I)

#de\
fine DRI(X) int (X); scanf("%d", &X)

#defin\
e RI(a) scanf("%I64d",&a);
typedef long long int LL;
using namespace std;

#de\
fine MAXN 10
LL A[MAXN][MAXN];

int main(){
    DRI(n);
    REP(i, n)REP(j, n)RI(A[i][j]);
    REP(k, n)REP(j, n)REP(i, n)A[i][j]=min(A[i][k]+A[k][j],A[i][j]);
    LL ans=0;
    REP(i, n)REP(j, n)ans=max(ans, A[i][j]);

    cout<<ans;
}

//ARGHHHH NOW I HAVE TO RECURSEEEEEE!
#include <bits/stdc++.h>
using namespace std;
int mat[20][20];
int n;
int get(int i, int j)
{
	scanf("%d", &mat[i][j]);
	j++;
	int foo;
	(j == n)?(i++, j = 0):foo=0;
	(i != n)?get(i, j): foo= 0;
	return 0;
}
int fw(int k, int i, int j)
{
	mat[i][j] = (mat[i][k]+mat[k][j]< mat[i][j])?(mat[i][k]+mat[k][j]):(mat[i][j]);
	j++;
	int foo;
	(j == n)?(i++, j = 0):foo=0;
	(i == n)?(k++, i = 0):foo=0;
	(k!= n)?fw(k, i, j): foo = 0;
	return 0;
}
int ans = -1e9;
int solve(int i, int j)
{
	ans = (mat[i][j] > ans)?mat[i][j]:ans;
	j++;
	int foo;
	(j == n)?(i++, j = 0):foo=0;
	(i != n)?solve(i, j):foo= 0;
	return 0;
}
int main()
{
	scanf("%d", &n);
	get(0, 0);fw(0, 0, 0); solve(0, 0);
	printf("%d\n", ans);
}

#include <algorithm>
#include <iostream>

using namespace std;

template <class Cond, class F>
void while_(Cond cond, F f) {
    static const void* labels[ ] = { &&enough, &&again };//Yet another GCC extension. :(
    goto *labels[cond()];
again:
    f();
    goto *labels[cond()];
enough:
    ;
}

template <class F>
void for_(int start, int end, F f) {
    while_([&]() { return start != end; }, [&]() {
        f(start++);
    });
}

int main() {
    int n;
    int a[10][10];
    while_([&]() { return bool(cin >> n); }, [&]() {
        for_(0, n, [&](int i) {
            for_(0, n, [&](int j) {
                cin >> a[i][j];
            });
        });
        for_(0, n, [&](int k) {
            for_(0, n, [&](int i) {
                for_(0, n, [&](int j) {
                    a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
                });
            });
        });
        int result = 0;
        for_(0, n, [&](int i) {
            result = max(result, *max_element(a[i], a[i] + n));
        });
        cout << result << '\n';
    });
}

#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>
using namespace std;
int ar[11][11];
int n;
bool readitem(int i, int j) {
  cin>>ar[i][j];
  return (j<n-1)?readitem(i,j+1)
        :(i<n-1)?readitem(i+1,0)
        :true;
}
bool fw(int k, int i, int j) {
  ar[i][j] = min(ar[i][j], ar[i][k]+ar[k][j]);
  return (j<n-1)?fw(k,i,j+1)
        :(i<n-1)?fw(k,i+1,0)
        :(k<n-1)?fw(k+1,0,0)
        :true;
}
int ans;
bool maxar(int i, int j) {
  ans = max(ans, ar[i][j]);
  return (j<n-1)?maxar(i,j+1)
        :(i<n-1)?maxar(i+1,0)
        :true;
}
int main() {
  cin>>n;
  ans = 0;
  readitem(0,0);
  fw(0,0,0);
  maxar(0,0);
  cout<<ans<<endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using ld = long double;
using pii = pair<int, int>;

template <class F> void bleh(int i, int n, const F &f)
{
	f(i); poop(i + 1, n, f);
}

template <class F> void poop(int i, int n, const  F &f)
{
	return (i == n) ? void() : bleh(i, n, f);
}

int main()
{
	int n;
	cin >> n;

	int oo = (int)1e9;
	vector<vector<int>> d(n, vector<int>(n, oo));

	poop(0, n, [&](int i) {
		d[i][i] = 0;
	});

	poop(0, n, [&](int i) {
		poop(0, n, [&](int j){
			cin >> d[i][j];
		});
	});

	poop(0, n, [&](int k){
		poop(0, n, [&](int i){
			poop(0, n, [&](int j){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			});
		});
	});

	int ans = 0;
	poop(0, n, [&](int i){
		poop(0, n, [&](int j){
			ans = (d[i][j] < oo) ? max(ans, d[i][j]) : ans;
		});
	});

	cout << ans << '\n';

	return 0;
}

// int main()
// {
// 	// cin.tie(0)->sync_with_stdio(0);
// 	// cin.exceptions(cin.failbit);
// 	// freopen(filename ".in", "r", stdin); freopen(filename ".out", "w", stdout);

// 	solve();

// 	return 0;
// }

#include <bits/stdc++.h>

#defin\
e climb fo\
r

using namespace std;

int n, ans = -0x7fffffff;
int f[20][20];

int main() {
	scanf("%d", &n);
	climb (int i = 1; i <= n; i ++) {
		climb (int j = 1; j <= n; j ++) {
			scanf("%d", &f[i][j]);
		}
	}
	climb (int k = 1; k <= n; k ++)
		climb (int i = 1; i <= n; i ++)
			climb (int j = 1; j <= n; j ++)
				f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
	climb (int i = 1; i <= n; i ++) {
		climb (int j = 1; j <= n; j ++) {
			ans = max(ans, f[i][j]);
		}
	}
	printf("%d\n", ans);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[100][100],n,ans;
int main()
{
cin>>n;
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)cin>>a[i][j];
f\
o\
r(int k=1;k<=n;++k)
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j) a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
f\
o\
r(int i=1;i<=n;++i)
f\
o\
r(int j=1;j<=n;++j)ans=max(ans,a[i][j]);
cout<<ans<<endl;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int dj[20][20];
#de\
fine fuck f\
o\
r
int min(int x,int y){
    return x<y?x:y;
}
int max(int x,int y){
    return x>y?x:y;
}
int main()
{
    int n,ans=0;
    cin>>n;
    fuck(int i=1;i<=n;++i)
    fuck(int j=1;j<=n;++j)
    cin>>dj[i][j];
    fuck(int k=1;k<=n;++k)
    fuck(int i=1;i<=n;++i)
    fuck(int j=1;j<=n;++j)
    dj[i][j]=min(dj[i][j],dj[i][k]+dj[k][j]);
    fuck(int i=1;i<=n;++i)
    fuck(int j=1;j<=n;++j)
    ans=max(ans,dj[i][j]);
    cout<<ans<<endl;
}

#include <iostream>

using namespace std;

int g[10][10];
int n;

int fw(int k, int i, int j){
    g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
    j++;
    i += (j/n);
    k += (i/n);
    j = (j%n);
    i = (i%n);
    return k == n ? 0 : fw(k, i, j);
}

int read(int i, int j){
    cin>>g[i][j];
    j++;
    i += (j/n);
    j = (j%n);
    return i == n ? 0 : read(i, j);
}

int m(int i, int j){
    return i == n ? 0 : max(g[i][j], m((j+1) == n ? i+1 : i, (j+1) == n ? 0 : j+1));
}

int main()
{
    cin>>n;
    read(0, 0);
    fw(0, 0, 0);
    cout<<m(0, 0)<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int N = (int) 10;

int n;
int mat[N][N];

int FOR3(int k, int i, int j, int n) {
    mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR3(k, i, j + 1, n) : 0;
}

int FOR2(int i, int j, int n) {
    FOR3(i, j, 0, n);
    return j + 1 < n ? FOR2(i, j + 1, n) : 0;
}

int FOR1(int i, int n) {
    FOR2(i, 0, n);
    return i + 1 < n ? FOR1(i + 1, n) : 0;
}

int FOR_INPUT2(int i, int j, int n) {
    cin >> mat[i][j];
    return j + 1 < n ? FOR_INPUT2(i, j + 1, n) : 0;
}

int FOR_INPUT1(int i, int n) {
    FOR_INPUT2(i, 0, n);
    return i + 1 < n ? FOR_INPUT1(i + 1, n) : 0;
}

int BILLY2(int i, int j, int n) {
    int ans = mat[i][j];
    int other = j + 1 < n ? BILLY2(i, j + 1, n) : 0;
    return max(ans, other);
}

int BILLY1(int i, int n) {
    int ans = BILLY2(i, 0, n);
    int other = i + 1 < n ? BILLY1(i + 1, n) : 0;
    return max(ans, other);
}

void solve() {
    cin >> n;
    FOR_INPUT1(0, n);
    FOR1(0, n);
    cout << BILLY1(0, n) << endl;
}

int main() {
    solve();
    return 0;
}

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <string.h>
#include <iostream>
using namespace std;

const int OO = (int) 1e8;
const int MOD = (int) 1e9+7;
const long double Pi = 3.1415926535897932384626433832795;
const int N = (int) 16+5;

int a[N][N],d[N][N],n,res;

int readj(int i,int j) {
    cin>>a[i][j];
    d[i][j]=a[i][j];
    return ((j<n)?readj(i,j+1):0);
}

int readi(int i) {
    readj(i,1);
    return ((i<=n)?(readi(i+1)):0);
}

int loopk(int i,int j,int k) {
    d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
    d[k][j]=min(d[k][j],d[j][k]);
    return (k<n)?loopk(i,j,k+1):0;
}

int loopj(int i,int j) {
    loopk(i,j,1);
    return (j<n)?loopj(i,j+1):0;
}

int loopi(int i) {
    loopj(i,1);
    return (i<n)?loopi(i+1):0;
}

int grj(int i,int j) {
    res=max(res,d[i][j]);
    return (j<n)?grj(i,j+1):0;
}

int gri(int i) {
    grj(i,i+1);
    return (i<n)?gri(i+1):0;
}

int main() {
    cin>>n;
    readi(1);
    //initi(1);
    loopi(1);
    res=d[1][2];
    gri(1);
    cout<<res;
}

#include <bits/stdc++.h>
using namespace std;

int n,a[15][15],mx;

void stop(){}

void Read2(int x, int y);
void Read1(int x){
    Read2(x,1);
    x<n?Read1(x+1):stop();
}

void Read2(int x,int y){
    cin >> a[x][y];
    y<n?Read2(x,y+1):stop();
}

void SP2(int x,int y);
void SP3(int x,int y,int z);
void SP1(int x){
    SP2(x,1);
    x<n?SP1(x+1):stop();
}

void SP2(int x,int y){
    SP3(x,y,1);
    y<n?SP2(x,y+1):stop();
}

void SP3(int x, int y, int z){
    (a[y][x]+a[x][z]<a[y][z] && x!=y && y!=z && x!=z) ? a[y][z]=a[y][x]+a[x][z] : a[y][z]+=0;
    z<n?SP3(x,y,z+1):stop();
}

void Find2(int x, int y);
void Find1(int x){
    Find2(x,1);
    x<n?Find1(x+1):stop();
}

void Find2(int x,int y){
    mx=max(mx,a[x][y]);
    y<n?Find2(x,y+1):stop();
}

int main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    Read1(1);
    SP1(1);
    Find1(1);
    cout << mx;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int MOD = 1e9 + 7; ll INF = 1e18;

int n, d[105][105];

#def\
ine fo fo\
r

int solve(){
	cin >> n;
	fo(int i=0;i<n;i++) fo(int j=0;j<n;j++) cin >> d[i][j];
	fo(int k=0;k<n;k++) fo(int i=0;i<n;i++) fo(int j=0;j<n;j++)
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	int mx = 0;
	fo(int i=0;i<n;i++) fo(int j=0;j<n;j++) mx = max(mx, d[i][j]);
	cout << mx << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; whi\
	le(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

#include <bits/stdc++.h>

#de\
fine shit(i,k,n) f\
or(int i=k;i <= n;i++)
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[110][110];
	shit(i,1,n)
		shit(j,1,n)
			cin >> a[i][j];
	shit(i,1,n)
	{
		shit(j,1,n)
		{
			shit(k,1,n)
			{
					a[j][k] = a[j][k] > a[j][i] + a[i][k] ? a[j][i] + a[i][k] : a[j][k];
			}
		}
	}
	int mx=0;
	shit(i,1,n)
		shit(j,1,n)
			mx = max(mx,a[i][j]);
	cout << mx;
}

#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
class solve
{

public:
	solve()
	{
		int SIZE;
		cin >> SIZE;
		vector<vector<int> > W(SIZE,vector<int>(SIZE));
		transform(W.begin(),W.end(),W.begin(),[](vector<int> a)\
		{
			transform(a.begin(),a.end(),a.begin(),[](int b){cin >>b;
			return b;});
			return a;
		});
		vector<int> w(SIZE);
		transform(w.begin(),w.end(),w.begin(),[&](const int &a)\
		{
			int k= &a-&w[0];
			vector<int> t(SIZE);
			transform(t.begin(),t.end(),t.begin(),[&](const int &b)\
			{
				int i=&b-&t[0];
				vector<int> z(SIZE);
				transform(z.begin(),z.end(),z.begin(),[&](const int &c)\
				{
					int j=&c-&z[0];
					W[i][j] = min(W[i][j], W[i][k] + W[k][j]);
					return 0;
				});
				return 0;
			});
			return 0;
		});
		int ans=0;
		transform(W.begin(),W.end(),W.begin(),[&](vector<int> a)\
		{
			int ans2=0;
			transform(a.begin(),a.end(),a.begin(),[&](int b){ans2=max(ans2,b);return ans2;});
			ans=max(ans2,ans);
			return a;
		});
		cout << ans << endl;
	}
};
int32_t main()
{
	new solve;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int dis[11][11],minn=-1;
int main()
{
int n;
cin>>n;
fo\
r(int i=1;i<=n;i++)
f\
or(int j=1;j<=n;j++)
cin>>dis[i][j];
fo\
r(int k=1;k<=n;k++)
fo\
r(int i=1;i<=n;i++)
f\
or(int j=1;j<=n;j++)
dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
fo\
r(int i=1;i<=n;i++)
f\
or(int j=1;j<=n;j++)
minn=max(minn,dis[i][j]);
cout<<minn;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
#defin\
e rep fo\
r
const int maxn=21+10;
int n,ans=0;
int maps[maxn][maxn];

int main()
{
	scanf("%d",&n);
	rep(int i=1;i<=n;i++)
	 rep(int j=1;j<=n;j++)
	   scanf("%d",&maps[i][j]);
	rep(int k=1;k<=n;k++)
	 rep(int i=1;i<=n;i++)
	  rep(int j=1;j<=n;j++)
	    maps[i][j]=min(maps[i][j],maps[i][k]+maps[k][j]);
	rep(int i=1;i<=n;i++)
	 rep(int j=1;j<=n;j++)
	   ans=max(ans,maps[i][j]);
	printf("%d",ans);
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

int graph[12][12];
int n, resp = 0;
int i = 0, j = 0, k = 0;

void nothing(){
}

void loop() {
    jmp_buf env;

    setjmp(env);

    cin >> graph[i][j];
    i = ((j+1 == n) ? i+1 : i);
    j = ((j+1 == n) ? 0 : j+1);
    return ((i == n && j == 0) ? nothing() : longjmp(env, 0));
}

void loop2() {
    jmp_buf env;

    setjmp(env);

    resp = max(resp, graph[i][j]);
    i = ((j+1 == n) ? i+1 : i);
    j = ((j+1 == n) ? 0 : j+1);

    return ((i == n && j == 0) ? nothing() : longjmp(env, 0));
}

void warshall(){
    jmp_buf env;

    setjmp(env);

    graph[i][j] = ((graph[i][j] > graph[i][k] + graph[k][j]) ? graph[i][k] + graph[k][j] : graph[i][j]);
    i = ((j+1 == n) ? i+1 : i);
    k = ((i == n) ? k+1 : k);
    i = ((i == n) ? 0 : i);
    j = ((j+1 == n) ? 0 : j+1);

    return ((k == n && i == 0) ? nothing() : longjmp(env, 0));
}

int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    loop();
    i = 0, j = 0;
    warshall();
    i = 0, j = 0;
    loop2();
    cout << resp << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[11][11],n;
int main()
{
	cin>>n;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
cin>>a[i][j];
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
int ans=-2e9;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	ans=max(ans,a[i][j]);
cout<<ans;
return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;
int a[15][15];
int d[15][15];
int n;
int maxx=-1;
int main(){
	cin>>n;
	fo\
r (int i=1;i<=n;i++){
		fo\
r(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	fo\
r(int k=1;k<=n;k++){
		fo\
r(int i=1;i<=n;i++){
			fo\
r(int j=1;j<=n;j++){
				i\
f(a[i][j]>a[i][k]+a[k][j]){
					a[i][j]=a[i][k]+a[k][j];
				}
			}
		}
	}
	fo\
r(int i=1;i<=n;i++){
		fo\
r(int j=1;j<=n;j++){
			maxx=max(a[i][j],maxx);
		}
	}
	printf("%d",maxx);
	return 0;
}

// <E.cpp> - 04/03/16 04:11:15
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long lol;
#defin\
e F(i,n) fo\
r(int i=1;i<=n;i++)
int a[12][12];
int main(){
	int n;cin>>n;
    F(i,n)F(j,n)cin>>a[i][j];
    F(k,n)F(i,n)F(j,n){
        a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
    }
    int ans=0;
    F(i,n)F(j,n)ans=max(ans,a[i][j]);
    cout<<ans;
	return 0;
}

#include<stdio.h>
int n, dis[12][12],ans =-2147483647;
int max(int x,int y){
	return x>y?x:y;
}
int min(int x,int y){
	return x<y?x:y;
}
int dfs1(int i,int j){
	scanf("%d",&dis[i][j]);
	return j==n&&i==n?0:(j==n?dfs1(i+1,1):dfs1(i,j+1));
}
int dfs2(int k,int i,int j){
	dis[i][j] = min(dis[i][j],dis[i][k]+dis[k][j]);
	return i==n&&j==n&&k==n?0:(i==n&&j==n?dfs2(k+1,1,1):(j==n?dfs2(k,i+1,1):dfs2(k,i,j+1)));
}
int dfs3(int i,int j){
	ans=max(ans,dis[i][j]);
	return j==n&&i==n?0:(j==n?dfs3(i+1,1):dfs3(i,j+1));
}
int main() {
    scanf("%d",&n);
 	dfs1(1,1);
 	dfs2(1,1,1);
 	dfs3(1,1);
    printf("%d", ans);
    return 0;
}

#include<iostream>
#include<cstdio>

using namespace std;

const int maxn = 15;
const int INF = 0x7fffffff;

int n, ans = -INF;
int a[maxn][maxn];

#defin\
e HAJSB fo\
r

int main()
{
	cin >> n;
	HAJSB(register int i = 1; i <= n; i++)
		HAJSB(register int j = 1; j <= n; j++) cin >> a[i][j];
	HAJSB(register int k = 1; k <= n; k++)
		HAJSB(register int i = 1; i <= n; i++)
			HAJSB(register int j = 1; j <= n; j++) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
	HAJSB(register int i = 1; i <= n; i++)
		HAJSB(register int j = 1; j <= n; j++) ans = max(ans, a[i][j]);
	cout << ans << '\n';
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#defin\
e o_0 fo\
r

#defin\
e x_x i\
f

#defin\
e u_u els\
e

vector <vector <long long> > vec;

int find(int i, int j, int lim)
{
    cin >> vec[i][j];
    x_x(j < lim)
    {
        find(i, j+1, lim);
    }
    u_u x_x(i < lim)
    {
	j = 0;
        find(i+1, j, lim);
    }
    return 0;
}

int main() {
	cout.precision(0);
	int V;
    cin >> V;
    vec = vector <vector <long long> > (V, vector <long long> (V));
    o_0(int i=0; i<V; ++i)
        o_0(int j=0; j<V; ++j)
            cin >> vec[i][j];

    o_0(int k = 0; k < V; ++k)
        o_0(int i = 0; i < V; ++i)
            o_0(int j = 0; j < V; ++j)
                vec[i][j] = min(vec[i][j], vec[i][k] + vec[k][j]);

    long long mx = -999999999;

    o_0(int i=0; i<V; ++i)
        o_0(int j=0; j<V; ++j)
            mx = max(mx, vec[i][j]);

    cout << mx << endl;
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
	int n,p,maxh;
	int a[11][11],v[11][11];
int fo1(int x,int y,int xs,int ys)
{
	scanf("%d",&a[x][y]);
	v[x][y]=a[x][y];
	p=y==ys?(x==xs?p:fo1(x+1,1,xs,ys)):fo1(x,y+1,xs,ys);
}
int fo2(int x,int y,int z)
{
	v[x][y]=min(v[x][y],v[x][z]+v[z][y]);
	p=y==n?(x==n?(z==n?p:fo2(1,1,z+1)):fo2(x+1,1,z)):fo2(x,y+1,z);
}
int fo3(int x,int y)
{
	maxh=max(maxh,v[x][y]);
	p=y==n?(x==n?p:fo3(x+1,1)):fo3(x,y+1);
}
int main()
{
	scanf("%d",&n);
	fo1(1,1,n,n);
	fo2(1,1,1);
	fo3(1,1);
	printf("%d",maxh);
	return 0;
}

#include<stdio.h>
int a[12][12],ans=-1;
int mn(int x,int y)
{
	return x<y?x:y;
}
int mx(int x,int y)
{
	return x>y?x:y;
}
int main()
{
	int n;
	scanf("%d",&n);
f\
o\
r(int i=1;i<=n;i++){
f\
o\
r(int j=1;j<=n;j++){
			scanf("%d",&a[i][j]);
		}
	}
f\
o\
r(int k=1;k<=n;k++){
f\
o\
r(int i=1;i<=n;i++){
f\
o\
r(int j=1;j<=n;j++){
				a[i][j]=mn(a[i][j],a[i][k]+a[k][j]);
			}
		}
	}
f\
o\
r(int i=1;i<=n;i++){
f\
o\
r(int j=1;j<=n;j++){
			ans=mx(ans,a[i][j]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include <cstdio>
#include <iostream>
using namespace std;

const int MAX_V = 15;

#defin\
e Fo2r(i, n) fo\
r (int i = 0; i < n; i++)

int d[MAX_V][MAX_V];
int V;

void warshall_floyd() {
	Fo2r(k, V) {
		Fo2r(i, V) {
			Fo2r(j, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
		}
	}
}

void solve() {
	warshall_floyd();
	int ans = 0;
	Fo2r(i, V) {
		Fo2r(j, V) {
			ans = max(ans, d[i][j]);
		}
	}
	printf("%d\n", ans);
}

int main() {
	scanf("%d", &V);
	Fo2r(i, V) {
		Fo2r(j, V) {
			scanf("%d", &d[i][j]);
		}
	}
	solve();
	return 0;
}

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstdio>
#include<string.h>
#include<map>
#include<queue>
#include<math.h>
#include<bitset>
#defin\
e F fo\
r
using namespace std;
int G[15][15]={0};
int main()
{
    int n;
    scanf("%d",&n);
    F(int i=0;i<n;i++)
     F(int j=0;j<n;j++)
     {
         scanf("%d",&G[i][j]);
     }
    F(int k=0;k<n;k++)
    {
        F(int i=0;i<n;i++)
        {
            F(int j=0;j<n;j++)
            {
                G[i][j]=(G[i][k]+G[k][j]<G[i][j])?(G[i][k]+G[k][j]):G[i][j];
            }
        }
    }
    int ans=0;
    F(int i=0;i<n;i++)
     F(int j=0;j<n;j++)
        ans=max(G[i][j],ans);
    printf("%d\n",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int arr[15][15];
int n;
void rec()
{
    return;
}
void recur2(int i,int j)
{
    cin>>arr[i][j];
    (j+1)<=n?recur2(i,j+1):rec();

}
int mx;
void recur1(int i)
{
//    cout<<i+1<<endl;
    recur2(i,1);
    (i+1)<=n?recur1(i+1):rec();
}
void recur4(int i,int j)
{
    mx=mx<arr[i][j]?arr[i][j]:mx;
    (j+1)<=n?recur4(i,j+1):rec();

}
void recur3(int i)
{
//    cout<<i+1<<endl;
    recur4(i,1);
    (i+1)<=n?recur3(i+1):rec();
}
void flo3(int k,int i,int j)
{
    arr[i][j]=arr[i][j]>arr[i][k]+arr[k][j]?arr[i][k]+arr[k][j]:arr[i][j];
    (j+1)<=n?flo3(k,i,j+1):rec();
}
void flo2(int k,int i)
{
    flo3(k,i,1);
    (i+1)<=n?flo2(k,i+1):rec();

}
void flo1(int k)
{
    flo2(k,1);
    (k+1)<=n?flo1(k+1):rec();
}
int main()
{
    memset(arr,0,sizeof arr);
    scanf("%d",&n);
    recur1(1);
    flo1(1);
    mx=-9999;
    recur3(1);
    cout<<mx<<endl;

    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<vector<int> > a;
vector<vector<int> > dist;
int N;
int res = 0;
//will not be used because we fill all pairs
const int INF = 100 + 1;
void f_input(int i, int j)
{
    cin >> a[i][j];
    dist[i][j] = a[i][j];
    j++;
    j == N? (i++, j = 0) : 0;
    i < N ? f_input(i, j): (void)0;
}
void f_fw(int k, int i, int j)
{
    //k i j
    //+ <= INF + INF <= 202
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    j ++;
    j == N ? (i ++, j = 0) : 0;
    i == N ? (k ++, i = 0, j = 0) : 0;
    //only we call f_fw(N - 1, N - 1, N - 1), k == N here
    k < N ? f_fw(k, i, j) : (void)0;
}

void f_res(int i, int j)
{
    res = max(res, dist[i][j]);
    j++;
    j == N ? (i ++, j = 0) : 0;
    i < N ? f_res(i, j) : (void)0;
}

int main(int argc, char **argv)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);
    cin >> N;
    a = vector<vector<int> >(N, vector<int> (N));
    dist = vector<vector<int> >(N, vector<int>(N, INF));
    f_input(0, 0);
    f_fw(0, 0, 0);
    f_res(0, 0);
    cout << res << endl;
    return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;

int n,a[11][11],ans=0,k;
int fk(int);
int fi(int,int);
int fj(int,int,int);

int read(int x,int y){
	scanf("%d",&a[x][y]);
	return (x==n && y==n)?0:((x<n && y==n)?read(x+1,1):read(x,y+1));
}

int fk(int k){
	return k==n+1?0:(fi(1,k),fk(k+1));
}

int fi(int i,int k){
	return i==n+1?0:(fj(1,i,k),fi(i+1,k));
}

int fj(int j,int i,int k){
	a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
	ans=(k==n)?max(ans,a[i][j]):ans;
	return j==n?0:fj(j+1,i,k);
}

int main(){
	scanf("%d",&n);
	read(1,1);
	fk(1);
	printf("%d",ans);
	return 0;
}

#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>
using namespace std;

int a[100][100];
int n;
int la()
{
    return 0;
}

int mem(int x, int y)
{
    cin >> a[x][y];
    int t = (y == n ? la() : mem(x, y + 1));
    return 0;
}

int kek(int x)
{
    int t = (x == n + 1 ? la() : mem(x, 1) ^ kek(x + 1));
    return 0;
}

int gogo(int i, int j, int k)
{
    a[j][k] = min(a[j][i] + a[i][k], a[j][k]);
    int t = (k == n ? la() : gogo(i, j, k + 1));
    return 0;
}

int go(int i, int j)
{
    int t = (j == n + 1 ? la() : gogo(i, j, 1) ^ go(i, j + 1));
    return 0;
}

int floyd(int v)
{
    int t = (v == n + 1 ? la() : go(v, 1) ^ floyd(v + 1));
    return 0;
}

int ans = 0;

int find(int v, int u)
{
    ans = max(ans, a[v][u]);
    int t = (u == n ? la() : find(v, u + 1));
    return 1;
}

int lol(int x)
{
    int t = (x == n + 1 ? la() : find(x, 1) ^ lol(x + 1));
    return 0;
}

int solve()
{
    ios::sync_with_stdio(0);
    cin >> n;
    kek(1);

    floyd(1);
    lol(1);
    cout << ans;
    cout << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#d\
e\
f\
i\
n\
e\
 \
f\
r\
 \
f\
o\
r
int graph[12][12],n;
int floyd(){
    fr(int k=0;k<n;k++){
        fr(int i=0;i<n;i++){
            fr(int j=0;j<n;j++){
                graph[i][j]=(graph[i][j]>graph[i][k]+graph[k][j])?graph[i][k]+graph[k][j]:graph[i][j];
            }
        }
    }
    int ans=0;
    fr(int i=0;i<n;i++){
        fr(int j=0;j<n;j++){
            ans=max(ans,graph[i][j]);
        }
    }
    return ans;
}
int main(){
    while(1==scanf("%d",&n)){
        fr(int i=0;i<n;i++)fr(int j=0;j<n;j++)scanf("%d",&graph[i][j]);
        cout<<floyd()<<endl;
    }
    return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int> > dis(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> dis[i][j];
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (dis[i][k] + dis[k][j] < dis[i][j]) {
					dis[i][j] = dis[i][k] + dis[k][j];
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j)
			ans = max(ans, dis[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

#include <stdio.h>
#include <algorithm>
using namespace std;
int a[110][110],n,ans,i,j,k;
int main () {
	scanf ("%d",&n);
	for (i=1;i<=n;++i)//ahkjdhkjshdkjhskjdhksjhdsd
		for (j=1;j<=n;++j)
			scanf ("%d",&a[i][j]);//duru
	for (k=1;k<=n;++k)
		for (i=1;i<=n;++i)//ashjahskjhkjas
			for (j=1;j<=n;++j)
				a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
	for (i=1;i<=n;++i)//jkhakjshkjashkjhaskja
		for (j=1;j<=n;++j)//sahkjshakjshkjahksjhkjas
			ans=max(ans,a[i][j]);
	printf ("%d\n",ans);
	return 0;
}

#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <deque>
#include <set>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <fstream>

using namespace std;

int g[11][11];
int n;
int mx = 0;

void read(int x, int y) {
    cin >> g[x][y];
    y++;
    x += y / n;
    y %= n;
    return x == n ? void() : read(x, y);
}

void go(int x, int y, int z) {
    g[x][y] = min(g[x][y], (x == y || x == z || y == z) ? g[x][y] : g[x][z] + g[z][y]);
    mx = max(mx, g[x][y]);
    z++;
    y += z / n;
    z %= n;
    x += y / n;
    y %= n;
    return x == n ? void() : go(x, y, z);
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n;
    read(0, 0);
    go(0, 0, 0);
    cout << mx;
    return 0;
}

#include <stdio.h>
#include <algorithm>
using namespace std;
int a[110][110],n,ans,i,j,k;
int main () {
	scanf ("%d",&n);
	for (i=1;i<=n;++i)
		for (j=1;j<=n;++j)
			scanf ("%d",&a[i][j]);
	for (k=1;k<=n;++k)
		for (i=1;i<=n;++i)
			for (j=1;j<=n;++j)
				a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
	for (i=1;i<=n;++i)
		for (j=1;j<=n;++j)
			ans=max(ans,a[i][j]);
	printf ("%d\n",ans);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <sstream>
#include <queue>
#include <fstream>
#include <cmath>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <numeric>
#include <iomanip>
#include <memory.h>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const ll LINF = 3e18;

//Hi, fellow programmer
//Welcome to my code

int n;
vector<vector<int> > d;
int ans = 0;

void action(int i, int j) {
	cin >> d[i][j];
}

int go(int curr, int top, int level, int sub = 0) {
	(level == 0) ? go(0, n, 1, curr) : action(sub, curr);
	curr++;
	return (curr == top) ? 0 : go(curr, top, level, sub);
}

int gof(int curr, int top, int level, int a, int b) {
	(level == 0) ? gof(0, n, 1, curr, 0) : (level == 1) ? gof(0, n, 2, a, curr) : ans = max(ans, d[b][curr] = min(d[b][curr], d[b][a] + d[a][curr]));
	curr++;
	return (curr == top) ? 0 : gof(curr, top, level, a, b);
}

int main() {
	//freopen("input.txt", "r", stdin);
	//iostream::sync_with_stdio(false);
	//srand(time(NULL));

	cin >> n;
	d.resize(n, vector<int> (n, 0));
	go(0, n, 0);
	gof(0, n, 0, 0, 0);
	cout << ans;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n;
int d[12][12];
int inf=(1e7);
int smieci;
int wiersz,kolumna;
int w,k;

int wczytaj()
{
	//cerr<<"# wczytaj " <<w<<" "<<k<<endl;
	int t;
	cin>>t;
	d[w][k]=t;
	k++;
	w+=(k==n);
	k%=n;
	return (w>=n ? 1 : wczytaj());
}
int ustaw()
{
	//cerr<<"# ustaw "<<w<<" "<<k<<endl;
	d[w][k]=(w==k ? 0 : inf);
	k++;
	w+=(k==n);
	k%=n;
	return (w>=n ? 1 : ustaw());
}
int kk,i,j;
int maks=-1;
int floyd()
{
	//cerr<<"# floyd "<<kk<<" "<<i<<" "<<j<<endl;
	d[i][j]=min(d[i][j],d[i][kk]+d[kk][j]);
	maks=( ( (d[i][j]!=inf) && (d[i][j]>maks) )? d[i][j] : maks );
	j++;
	i+=(j==n);
	kk+=(i==n);
	j%=n;
	i%=n;
	//kk%=n;
	return (kk>=n ? 1 : floyd());
}
int allpair()
{
	floyd();
	k++;
	w+=(k==n);
	k%=n;
	return (w>=n ? 1 : wczytaj());
}
int main()
{

	cin>>n;
	w=k=0;
	ustaw();
	//cerr<<"ustawil"<<endl;
	w=k=0;
	wczytaj();
	w=k=0;
	allpair();
	//floyd();
	cout<<maks<<endl;
}

#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
//#define ll   long long
//#define pb   push_back
//#define mp   make_pair
//#define orz  1000000007
//作者:中国江苏南京丁天行
//from CrAzYUnIoN
//I prefer being hacked than being FST
using namespace std;
int n,ans,a[15][15],k,i,j,rev;
int cty(int x,int y){
     scanf("%d",a[x]+y);
     y==n?y=1,x++:y++;
     x<=n?rev=cty(x,y):x=x;
     return 0;
}

int cty0(int x,int y){
     ans=max(ans,a[x][y]);
     y==n?y=1,x++:y++;
     x<=n?rev=cty0(x,y):x=x;
     return 0;
}
int cty3(){
     a[i][j]=min(a[i][k]+a[k][j],a[i][j]);
     j++;
     j<=n?rev=cty3():j=j;
     return 0;
}
int cty2(){
     j=1;
     rev=cty3();
     i++;
     i<=n?rev=cty2():i=i;
     return 0;
}
int cty1(){
     i=1;
     rev=cty2();
     k++;
     k<=n?rev=cty1():k=k;
     return 0;
}
int main()
{
    scanf("%d",&n);
    cty(1,1);
    k=1;
    cty1();
    cty0(1,1);
    printf("%d\n",ans);
//	system("pause");
	return 0;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cassert>
#include<climits>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<numeric>
#include<iomanip>
#include<bitset>
#include<sstream>
#include<fstream>
#define debug puts("-----")
#define pi (acos(-1.0))
#define eps (1e-8)
#define inf (1<<30)
#define INF (1ll<<62)
using namespace std;
int main()
{
    for (int i=0;i<5;i++) ;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n,a[15][15],mx;

void stop(){}

void Read2(int x, int y);
void Read1(int x){
    Read2(x,1);
    x<n?Read1(x+1):stop();
}

void Read2(int x,int y){
    cin >> a[x][y];
    y<n?Read2(x,y+1):stop();
}

void SP2(int x,int y);
void SP3(int x,int y,int z);
void SP1(int x){
    SP2(x,1);
    x<n?SP1(x+1):stop();
}

void SP2(int x,int y){
    SP3(x,y,1);
    y<n?SP2(x,y+1):stop();
}

void SP3(int x, int y, int z){
    (a[x][y]+a[y][z]<a[x][z] && x!=y && y!=z && x!=z) ? a[x][z]=a[x][y]+a[y][z] : a[x][y]+=0;
    z<n?SP3(x,y,z+1):stop();
}

void Find2(int x, int y);
void Find1(int x){
    Find2(x,1);
    x<n?Find1(x+1):stop();
}

void Find2(int x,int y){
    mx=max(mx,a[x][y]);
    y<n?Find2(x,y+1):stop();
}

int main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    Read1(1);
    SP1(1);
    Find1(1);
    cout << mx;
}
//

#include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip> // for cout<<fixed<<setprecision(5);
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>
using namespace std;
int ar[11][11];
int n;
bool readitem(int i, int j) {
  cin>>ar[i][j];
  return (j<n-1)?readitem(i,j+1)
        :(i<n-1)?readitem(i+1,0)
        :true;
}
bool fw(int k, int i, int j) {
  ar[i][j] = min(ar[i][j], ar[i][k]+ar[k][j]);
  return (j<n-1)?fw(k,i,j+1)
        :(i<n-1)?fw(k,i+1,0)
        :(k<n-1)?fw(k+1,0,0)
        :true;
}
int ans;
bool maxar(int i, int j) {
  ans = max(ans, ar[i][j]);
  return (j<n-1)?maxar(i,j+1)
        :(i<n-1)?maxar(i+1,0)
        :true;
}
int main() {
  cin>>n;
  ans = 0;
  readitem(0,0);
  fw(0,0,0);
  maxar(0,0);
  cout<<ans<<endl;
  return 0;
}

#include <algorithm>
#include <bitset>
#include <deque>
#include <iomanip> // for cout<<fixed<<setprecision(5);
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <vector>
#define ll long long
using namespace std;
int ar[11][11];
int n;
bool readitem(int i, int j) {
  cin>>ar[i][j];
  return (j<n-1)?readitem(i,j+1)
        :(i<n-1)?readitem(i+1,0)
        :true;
}
bool fw(int k, int i, int j) {
  ar[i][j] = min(ar[i][j], ar[i][k]+ar[k][j]);
  return (j<n-1)?fw(k,i,j+1)
        :(i<n-1)?fw(k,i+1,0)
        :(k<n-1)?fw(k+1,0,0)
        :true;
}
int ans;
bool maxar(int i, int j) {
  ans = max(ans, ar[i][j]);
  return (j<n-1)?maxar(i,j+1)
        :(i<n-1)?maxar(i+1,0)
        :true;
}
int main() {
  cin>>n;
  ans = 0;
  readitem(0,0);
  fw(0,0,0);
  maxar(0,0);
  cout<<ans<<endl;
  return 0;
}

/* -*- coding: utf-8 -*-
 *
 * 0656E.cc: E. Out of Controls
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 10;

/* typedef */

/* global variables */

int as[MAX_N][MAX_N];

/* subroutines */

inline void setmin(int &a, int b) { a = min(a, b); }
inline void setmax(int &a, int b) { a = max(a, b); }

/* main */

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", as[i] + j);

  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
	setmin(as[i][j], as[i][k] + as[k][j]);

  int maxa = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      setmax(maxa, as[i][j]);

  printf("%d\n", maxa);
  return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <stack>
#include <set>
#include <algorithm>
#include <bitset>
#include <functional>
#include <ctime>
#include <cassert>
#include <valarray>
#include <unordered_map>
#pragma comment(linker, "/STACK:167772160")

using namespace std;
#pragma region TypeDefs

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef vector< vector<int> > vvint;

#pragma endregion

const int INF = 1e9 + 10;
const ll LINF = (ll) 2e18 + 10;
const ld PI = acos(-1);
const ld eps = 1e-8;
const ld EPS = 1e-12;

const int N = 10;
int n, i, j, k, c, res = 0;
int dists[N][N];

void read_next()
{
	cin >> dists[i][j];
	++j == n ? 1 : read_next();
}

void read()
{
	j = 0;
	read_next();
	++i == n ? 1 : read();
}

void calc_next2()
{
	dists[i][j] = min(dists[i][j], dists[i][k] + dists[k][j]);
	++j == n ? 1 : calc_next2();
}

void calc_next1()
{
	j = 0;
	calc_next2();
	++i == n ? 1 : calc_next1();
}

void calc()
{
	i = 0;
	calc_next1();
	++k == n ? 1 : calc();
}

void relax1()
{
	res = max(res, dists[i][j]);
	++j == n ? 1 : relax1();
}

void relax()
{
	j = 0;
	relax1();
	++i == n ? 1 : relax();
}

void solve()
{
	cin >> n;
	i = 0;
	read();

	k = 0;
	calc();

	i = 0;
	relax();

	cout << res;
}

int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0);

	solve();

#ifdef LOCAL
	fprintf(stderr, "\n\nTime: %.3f", (double) clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)

#define DRI(a) int a; scanf("%d ", &a);
#define DRII(a, b) int a, b; scanf("%d %d ", &a, &b);
#define DRIII(a, b, c) int a, b, c; scanf("%d %d %d ", &a, &b, &c);
#define DRIIII(a, b, c, d) int a, b, c, d; scanf("%d %d %d %d ", &a, &b, &c, &d);
#define RI(a) scanf("%d ", &a);
#define RII(a, b) scanf("%d %d ", &a, &b);
#define RIII(a, b, c) scanf("%d %d %d ", &a, &b, &c);
#define RIIII(a, b, c, d) scanf("%d %d %d %d ", &a, &b, &c, &d);

#define PB push_back
#define MP make_pair

#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int,int>

#define ll long long
#define ull unsigned long long

#define MM(co, cim) memset((co), (cim), sizeof((co)))

#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;

int D[107];

void FW() {
D[0] = min(D[0],D[0]+D[0]);
D[1] = min(D[1],D[0]+D[1]);
D[2] = min(D[2],D[0]+D[2]);
D[3] = min(D[3],D[0]+D[3]);
D[4] = min(D[4],D[0]+D[4]);
D[5] = min(D[5],D[0]+D[5]);
D[6] = min(D[6],D[0]+D[6]);
D[7] = min(D[7],D[0]+D[7]);
D[8] = min(D[8],D[0]+D[8]);
D[9] = min(D[9],D[0]+D[9]);
D[10] = min(D[10],D[10]+D[0]);
D[11] = min(D[11],D[10]+D[1]);
D[12] = min(D[12],D[10]+D[2]);
D[13] = min(D[13],D[10]+D[3]);
D[14] = min(D[14],D[10]+D[4]);
D[15] = min(D[15],D[10]+D[5]);
D[16] = min(D[16],D[10]+D[6]);
D[17] = min(D[17],D[10]+D[7]);
D[18] = min(D[18],D[10]+D[8]);
D[19] = min(D[19],D[10]+D[9]);
D[20] = min(D[20],D[20]+D[0]);
D[21] = min(D[21],D[20]+D[1]);
D[22] = min(D[22],D[20]+D[2]);
D[23] = min(D[23],D[20]+D[3]);
D[24] = min(D[24],D[20]+D[4]);
D[25] = min(D[25],D[20]+D[5]);
D[26] = min(D[26],D[20]+D[6]);
D[27] = min(D[27],D[20]+D[7]);
D[28] = min(D[28],D[20]+D[8]);
D[29] = min(D[29],D[20]+D[9]);
D[30] = min(D[30],D[30]+D[0]);
D[31] = min(D[31],D[30]+D[1]);
D[32] = min(D[32],D[30]+D[2]);
D[33] = min(D[33],D[30]+D[3]);
D[34] = min(D[34],D[30]+D[4]);
D[35] = min(D[35],D[30]+D[5]);
D[36] = min(D[36],D[30]+D[6]);
D[37] = min(D[37],D[30]+D[7]);
D[38] = min(D[38],D[30]+D[8]);
D[39] = min(D[39],D[30]+D[9]);
D[40] = min(D[40],D[40]+D[0]);
D[41] = min(D[41],D[40]+D[1]);
D[42] = min(D[42],D[40]+D[2]);
D[43] = min(D[43],D[40]+D[3]);
D[44] = min(D[44],D[40]+D[4]);
D[45] = min(D[45],D[40]+D[5]);
D[46] = min(D[46],D[40]+D[6]);
D[47] = min(D[47],D[40]+D[7]);
D[48] = min(D[48],D[40]+D[8]);
D[49] = min(D[49],D[40]+D[9]);
D[50] = min(D[50],D[50]+D[0]);
D[51] = min(D[51],D[50]+D[1]);
D[52] = min(D[52],D[50]+D[2]);
D[53] = min(D[53],D[50]+D[3]);
D[54] = min(D[54],D[50]+D[4]);
D[55] = min(D[55],D[50]+D[5]);
D[56] = min(D[56],D[50]+D[6]);
D[57] = min(D[57],D[50]+D[7]);
D[58] = min(D[58],D[50]+D[8]);
D[59] = min(D[59],D[50]+D[9]);
D[60] = min(D[60],D[60]+D[0]);
D[61] = min(D[61],D[60]+D[1]);
D[62] = min(D[62],D[60]+D[2]);
D[63] = min(D[63],D[60]+D[3]);
D[64] = min(D[64],D[60]+D[4]);
D[65] = min(D[65],D[60]+D[5]);
D[66] = min(D[66],D[60]+D[6]);
D[67] = min(D[67],D[60]+D[7]);
D[68] = min(D[68],D[60]+D[8]);
D[69] = min(D[69],D[60]+D[9]);
D[70] = min(D[70],D[70]+D[0]);
D[71] = min(D[71],D[70]+D[1]);
D[72] = min(D[72],D[70]+D[2]);
D[73] = min(D[73],D[70]+D[3]);
D[74] = min(D[74],D[70]+D[4]);
D[75] = min(D[75],D[70]+D[5]);
D[76] = min(D[76],D[70]+D[6]);
D[77] = min(D[77],D[70]+D[7]);
D[78] = min(D[78],D[70]+D[8]);
D[79] = min(D[79],D[70]+D[9]);
D[80] = min(D[80],D[80]+D[0]);
D[81] = min(D[81],D[80]+D[1]);
D[82] = min(D[82],D[80]+D[2]);
D[83] = min(D[83],D[80]+D[3]);
D[84] = min(D[84],D[80]+D[4]);
D[85] = min(D[85],D[80]+D[5]);
D[86] = min(D[86],D[80]+D[6]);
D[87] = min(D[87],D[80]+D[7]);
D[88] = min(D[88],D[80]+D[8]);
D[89] = min(D[89],D[80]+D[9]);
D[90] = min(D[90],D[90]+D[0]);
D[91] = min(D[91],D[90]+D[1]);
D[92] = min(D[92],D[90]+D[2]);
D[93] = min(D[93],D[90]+D[3]);
D[94] = min(D[94],D[90]+D[4]);
D[95] = min(D[95],D[90]+D[5]);
D[96] = min(D[96],D[90]+D[6]);
D[97] = min(D[97],D[90]+D[7]);
D[98] = min(D[98],D[90]+D[8]);
D[99] = min(D[99],D[90]+D[9]);
D[0] = min(D[0],D[1]+D[10]);
D[1] = min(D[1],D[1]+D[11]);
D[2] = min(D[2],D[1]+D[12]);
D[3] = min(D[3],D[1]+D[13]);
D[4] = min(D[4],D[1]+D[14]);
D[5] = min(D[5],D[1]+D[15]);
D[6] = min(D[6],D[1]+D[16]);
D[7] = min(D[7],D[1]+D[17]);
D[8] = min(D[8],D[1]+D[18]);
D[9] = min(D[9],D[1]+D[19]);
D[10] = min(D[10],D[11]+D[10]);
D[11] = min(D[11],D[11]+D[11]);
D[12] = min(D[12],D[11]+D[12]);
D[13] = min(D[13],D[11]+D[13]);
D[14] = min(D[14],D[11]+D[14]);
D[15] = min(D[15],D[11]+D[15]);
D[16] = min(D[16],D[11]+D[16]);
D[17] = min(D[17],D[11]+D[17]);
D[18] = min(D[18],D[11]+D[18]);
D[19] = min(D[19],D[11]+D[19]);
D[20] = min(D[20],D[21]+D[10]);
D[21] = min(D[21],D[21]+D[11]);
D[22] = min(D[22],D[21]+D[12]);
D[23] = min(D[23],D[21]+D[13]);
D[24] = min(D[24],D[21]+D[14]);
D[25] = min(D[25],D[21]+D[15]);
D[26] = min(D[26],D[21]+D[16]);
D[27] = min(D[27],D[21]+D[17]);
D[28] = min(D[28],D[21]+D[18]);
D[29] = min(D[29],D[21]+D[19]);
D[30] = min(D[30],D[31]+D[10]);
D[31] = min(D[31],D[31]+D[11]);
D[32] = min(D[32],D[31]+D[12]);
D[33] = min(D[33],D[31]+D[13]);
D[34] = min(D[34],D[31]+D[14]);
D[35] = min(D[35],D[31]+D[15]);
D[36] = min(D[36],D[31]+D[16]);
D[37] = min(D[37],D[31]+D[17]);
D[38] = min(D[38],D[31]+D[18]);
D[39] = min(D[39],D[31]+D[19]);
D[40] = min(D[40],D[41]+D[10]);
D[41] = min(D[41],D[41]+D[11]);
D[42] = min(D[42],D[41]+D[12]);
D[43] = min(D[43],D[41]+D[13]);
D[44] = min(D[44],D[41]+D[14]);
D[45] = min(D[45],D[41]+D[15]);
D[46] = min(D[46],D[41]+D[16]);
D[47] = min(D[47],D[41]+D[17]);
D[48] = min(D[48],D[41]+D[18]);
D[49] = min(D[49],D[41]+D[19]);
D[50] = min(D[50],D[51]+D[10]);
D[51] = min(D[51],D[51]+D[11]);
D[52] = min(D[52],D[51]+D[12]);
D[53] = min(D[53],D[51]+D[13]);
D[54] = min(D[54],D[51]+D[14]);
D[55] = min(D[55],D[51]+D[15]);
D[56] = min(D[56],D[51]+D[16]);
D[57] = min(D[57],D[51]+D[17]);
D[58] = min(D[58],D[51]+D[18]);
D[59] = min(D[59],D[51]+D[19]);
D[60] = min(D[60],D[61]+D[10]);
D[61] = min(D[61],D[61]+D[11]);
D[62] = min(D[62],D[61]+D[12]);
D[63] = min(D[63],D[61]+D[13]);
D[64] = min(D[64],D[61]+D[14]);
D[65] = min(D[65],D[61]+D[15]);
D[66] = min(D[66],D[61]+D[16]);
D[67] = min(D[67],D[61]+D[17]);
D[68] = min(D[68],D[61]+D[18]);
D[69] = min(D[69],D[61]+D[19]);
D[70] = min(D[70],D[71]+D[10]);
D[71] = min(D[71],D[71]+D[11]);
D[72] = min(D[72],D[71]+D[12]);
D[73] = min(D[73],D[71]+D[13]);
D[74] = min(D[74],D[71]+D[14]);
D[75] = min(D[75],D[71]+D[15]);
D[76] = min(D[76],D[71]+D[16]);
D[77] = min(D[77],D[71]+D[17]);
D[78] = min(D[78],D[71]+D[18]);
D[79] = min(D[79],D[71]+D[19]);
D[80] = min(D[80],D[81]+D[10]);
D[81] = min(D[81],D[81]+D[11]);
D[82] = min(D[82],D[81]+D[12]);
D[83] = min(D[83],D[81]+D[13]);
D[84] = min(D[84],D[81]+D[14]);
D[85] = min(D[85],D[81]+D[15]);
D[86] = min(D[86],D[81]+D[16]);
D[87] = min(D[87],D[81]+D[17]);
D[88] = min(D[88],D[81]+D[18]);
D[89] = min(D[89],D[81]+D[19]);
D[90] = min(D[90],D[91]+D[10]);
D[91] = min(D[91],D[91]+D[11]);
D[92] = min(D[92],D[91]+D[12]);
D[93] = min(D[93],D[91]+D[13]);
D[94] = min(D[94],D[91]+D[14]);
D[95] = min(D[95],D[91]+D[15]);
D[96] = min(D[96],D[91]+D[16]);
D[97] = min(D[97],D[91]+D[17]);
D[98] = min(D[98],D[91]+D[18]);
D[99] = min(D[99],D[91]+D[19]);
D[0] = min(D[0],D[2]+D[20]);
D[1] = min(D[1],D[2]+D[21]);
D[2] = min(D[2],D[2]+D[22]);
D[3] = min(D[3],D[2]+D[23]);
D[4] = min(D[4],D[2]+D[24]);
D[5] = min(D[5],D[2]+D[25]);
D[6] = min(D[6],D[2]+D[26]);
D[7] = min(D[7],D[2]+D[27]);
D[8] = min(D[8],D[2]+D[28]);
D[9] = min(D[9],D[2]+D[29]);
D[10] = min(D[10],D[12]+D[20]);
D[11] = min(D[11],D[12]+D[21]);
D[12] = min(D[12],D[12]+D[22]);
D[13] = min(D[13],D[12]+D[23]);
D[14] = min(D[14],D[12]+D[24]);
D[15] = min(D[15],D[12]+D[25]);
D[16] = min(D[16],D[12]+D[26]);
D[17] = min(D[17],D[12]+D[27]);
D[18] = min(D[18],D[12]+D[28]);
D[19] = min(D[19],D[12]+D[29]);
D[20] = min(D[20],D[22]+D[20]);
D[21] = min(D[21],D[22]+D[21]);
D[22] = min(D[22],D[22]+D[22]);
D[23] = min(D[23],D[22]+D[23]);
D[24] = min(D[24],D[22]+D[24]);
D[25] = min(D[25],D[22]+D[25]);
D[26] = min(D[26],D[22]+D[26]);
D[27] = min(D[27],D[22]+D[27]);
D[28] = min(D[28],D[22]+D[28]);
D[29] = min(D[29],D[22]+D[29]);
D[30] = min(D[30],D[32]+D[20]);
D[31] = min(D[31],D[32]+D[21]);
D[32] = min(D[32],D[32]+D[22]);
D[33] = min(D[33],D[32]+D[23]);
D[34] = min(D[34],D[32]+D[24]);
D[35] = min(D[35],D[32]+D[25]);
D[36] = min(D[36],D[32]+D[26]);
D[37] = min(D[37],D[32]+D[27]);
D[38] = min(D[38],D[32]+D[28]);
D[39] = min(D[39],D[32]+D[29]);
D[40] = min(D[40],D[42]+D[20]);
D[41] = min(D[41],D[42]+D[21]);
D[42] = min(D[42],D[42]+D[22]);
D[43] = min(D[43],D[42]+D[23]);
D[44] = min(D[44],D[42]+D[24]);
D[45] = min(D[45],D[42]+D[25]);
D[46] = min(D[46],D[42]+D[26]);
D[47] = min(D[47],D[42]+D[27]);
D[48] = min(D[48],D[42]+D[28]);
D[49] = min(D[49],D[42]+D[29]);
D[50] = min(D[50],D[52]+D[20]);
D[51] = min(D[51],D[52]+D[21]);
D[52] = min(D[52],D[52]+D[22]);
D[53] = min(D[53],D[52]+D[23]);
D[54] = min(D[54],D[52]+D[24]);
D[55] = min(D[55],D[52]+D[25]);
D[56] = min(D[56],D[52]+D[26]);
D[57] = min(D[57],D[52]+D[27]);
D[58] = min(D[58],D[52]+D[28]);
D[59] = min(D[59],D[52]+D[29]);
D[60] = min(D[60],D[62]+D[20]);
D[61] = min(D[61],D[62]+D[21]);
D[62] = min(D[62],D[62]+D[22]);
D[63] = min(D[63],D[62]+D[23]);
D[64] = min(D[64],D[62]+D[24]);
D[65] = min(D[65],D[62]+D[25]);
D[66] = min(D[66],D[62]+D[26]);
D[67] = min(D[67],D[62]+D[27]);
D[68] = min(D[68],D[62]+D[28]);
D[69] = min(D[69],D[62]+D[29]);
D[70] = min(D[70],D[72]+D[20]);
D[71] = min(D[71],D[72]+D[21]);
D[72] = min(D[72],D[72]+D[22]);
D[73] = min(D[73],D[72]+D[23]);
D[74] = min(D[74],D[72]+D[24]);
D[75] = min(D[75],D[72]+D[25]);
D[76] = min(D[76],D[72]+D[26]);
D[77] = min(D[77],D[72]+D[27]);
D[78] = min(D[78],D[72]+D[28]);
D[79] = min(D[79],D[72]+D[29]);
D[80] = min(D[80],D[82]+D[20]);
D[81] = min(D[81],D[82]+D[21]);
D[82] = min(D[82],D[82]+D[22]);
D[83] = min(D[83],D[82]+D[23]);
D[84] = min(D[84],D[82]+D[24]);
D[85] = min(D[85],D[82]+D[25]);
D[86] = min(D[86],D[82]+D[26]);
D[87] = min(D[87],D[82]+D[27]);
D[88] = min(D[88],D[82]+D[28]);
D[89] = min(D[89],D[82]+D[29]);
D[90] = min(D[90],D[92]+D[20]);
D[91] = min(D[91],D[92]+D[21]);
D[92] = min(D[92],D[92]+D[22]);
D[93] = min(D[93],D[92]+D[23]);
D[94] = min(D[94],D[92]+D[24]);
D[95] = min(D[95],D[92]+D[25]);
D[96] = min(D[96],D[92]+D[26]);
D[97] = min(D[97],D[92]+D[27]);
D[98] = min(D[98],D[92]+D[28]);
D[99] = min(D[99],D[92]+D[29]);
D[0] = min(D[0],D[3]+D[30]);
D[1] = min(D[1],D[3]+D[31]);
D[2] = min(D[2],D[3]+D[32]);
D[3] = min(D[3],D[3]+D[33]);
D[4] = min(D[4],D[3]+D[34]);
D[5] = min(D[5],D[3]+D[35]);
D[6] = min(D[6],D[3]+D[36]);
D[7] = min(D[7],D[3]+D[37]);
D[8] = min(D[8],D[3]+D[38]);
D[9] = min(D[9],D[3]+D[39]);
D[10] = min(D[10],D[13]+D[30]);
D[11] = min(D[11],D[13]+D[31]);
D[12] = min(D[12],D[13]+D[32]);
D[13] = min(D[13],D[13]+D[33]);
D[14] = min(D[14],D[13]+D[34]);
D[15] = min(D[15],D[13]+D[35]);
D[16] = min(D[16],D[13]+D[36]);
D[17] = min(D[17],D[13]+D[37]);
D[18] = min(D[18],D[13]+D[38]);
D[19] = min(D[19],D[13]+D[39]);
D[20] = min(D[20],D[23]+D[30]);
D[21] = min(D[21],D[23]+D[31]);
D[22] = min(D[22],D[23]+D[32]);
D[23] = min(D[23],D[23]+D[33]);
D[24] = min(D[24],D[23]+D[34]);
D[25] = min(D[25],D[23]+D[35]);
D[26] = min(D[26],D[23]+D[36]);
D[27] = min(D[27],D[23]+D[37]);
D[28] = min(D[28],D[23]+D[38]);
D[29] = min(D[29],D[23]+D[39]);
D[30] = min(D[30],D[33]+D[30]);
D[31] = min(D[31],D[33]+D[31]);
D[32] = min(D[32],D[33]+D[32]);
D[33] = min(D[33],D[33]+D[33]);
D[34] = min(D[34],D[33]+D[34]);
D[35] = min(D[35],D[33]+D[35]);
D[36] = min(D[36],D[33]+D[36]);
D[37] = min(D[37],D[33]+D[37]);
D[38] = min(D[38],D[33]+D[38]);
D[39] = min(D[39],D[33]+D[39]);
D[40] = min(D[40],D[43]+D[30]);
D[41] = min(D[41],D[43]+D[31]);
D[42] = min(D[42],D[43]+D[32]);
D[43] = min(D[43],D[43]+D[33]);
D[44] = min(D[44],D[43]+D[34]);
D[45] = min(D[45],D[43]+D[35]);
D[46] = min(D[46],D[43]+D[36]);
D[47] = min(D[47],D[43]+D[37]);
D[48] = min(D[48],D[43]+D[38]);
D[49] = min(D[49],D[43]+D[39]);
D[50] = min(D[50],D[53]+D[30]);
D[51] = min(D[51],D[53]+D[31]);
D[52] = min(D[52],D[53]+D[32]);
D[53] = min(D[53],D[53]+D[33]);
D[54] = min(D[54],D[53]+D[34]);
D[55] = min(D[55],D[53]+D[35]);
D[56] = min(D[56],D[53]+D[36]);
D[57] = min(D[57],D[53]+D[37]);
D[58] = min(D[58],D[53]+D[38]);
D[59] = min(D[59],D[53]+D[39]);
D[60] = min(D[60],D[63]+D[30]);
D[61] = min(D[61],D[63]+D[31]);
D[62] = min(D[62],D[63]+D[32]);
D[63] = min(D[63],D[63]+D[33]);
D[64] = min(D[64],D[63]+D[34]);
D[65] = min(D[65],D[63]+D[35]);
D[66] = min(D[66],D[63]+D[36]);
D[67] = min(D[67],D[63]+D[37]);
D[68] = min(D[68],D[63]+D[38]);
D[69] = min(D[69],D[63]+D[39]);
D[70] = min(D[70],D[73]+D[30]);
D[71] = min(D[71],D[73]+D[31]);
D[72] = min(D[72],D[73]+D[32]);
D[73] = min(D[73],D[73]+D[33]);
D[74] = min(D[74],D[73]+D[34]);
D[75] = min(D[75],D[73]+D[35]);
D[76] = min(D[76],D[73]+D[36]);
D[77] = min(D[77],D[73]+D[37]);
D[78] = min(D[78],D[73]+D[38]);
D[79] = min(D[79],D[73]+D[39]);
D[80] = min(D[80],D[83]+D[30]);
D[81] = min(D[81],D[83]+D[31]);
D[82] = min(D[82],D[83]+D[32]);
D[83] = min(D[83],D[83]+D[33]);
D[84] = min(D[84],D[83]+D[34]);
D[85] = min(D[85],D[83]+D[35]);
D[86] = min(D[86],D[83]+D[36]);
D[87] = min(D[87],D[83]+D[37]);
D[88] = min(D[88],D[83]+D[38]);
D[89] = min(D[89],D[83]+D[39]);
D[90] = min(D[90],D[93]+D[30]);
D[91] = min(D[91],D[93]+D[31]);
D[92] = min(D[92],D[93]+D[32]);
D[93] = min(D[93],D[93]+D[33]);
D[94] = min(D[94],D[93]+D[34]);
D[95] = min(D[95],D[93]+D[35]);
D[96] = min(D[96],D[93]+D[36]);
D[97] = min(D[97],D[93]+D[37]);
D[98] = min(D[98],D[93]+D[38]);
D[99] = min(D[99],D[93]+D[39]);
D[0] = min(D[0],D[4]+D[40]);
D[1] = min(D[1],D[4]+D[41]);
D[2] = min(D[2],D[4]+D[42]);
D[3] = min(D[3],D[4]+D[43]);
D[4] = min(D[4],D[4]+D[44]);
D[5] = min(D[5],D[4]+D[45]);
D[6] = min(D[6],D[4]+D[46]);
D[7] = min(D[7],D[4]+D[47]);
D[8] = min(D[8],D[4]+D[48]);
D[9] = min(D[9],D[4]+D[49]);
D[10] = min(D[10],D[14]+D[40]);
D[11] = min(D[11],D[14]+D[41]);
D[12] = min(D[12],D[14]+D[42]);
D[13] = min(D[13],D[14]+D[43]);
D[14] = min(D[14],D[14]+D[44]);
D[15] = min(D[15],D[14]+D[45]);
D[16] = min(D[16],D[14]+D[46]);
D[17] = min(D[17],D[14]+D[47]);
D[18] = min(D[18],D[14]+D[48]);
D[19] = min(D[19],D[14]+D[49]);
D[20] = min(D[20],D[24]+D[40]);
D[21] = min(D[21],D[24]+D[41]);
D[22] = min(D[22],D[24]+D[42]);
D[23] = min(D[23],D[24]+D[43]);
D[24] = min(D[24],D[24]+D[44]);
D[25] = min(D[25],D[24]+D[45]);
D[26] = min(D[26],D[24]+D[46]);
D[27] = min(D[27],D[24]+D[47]);
D[28] = min(D[28],D[24]+D[48]);
D[29] = min(D[29],D[24]+D[49]);
D[30] = min(D[30],D[34]+D[40]);
D[31] = min(D[31],D[34]+D[41]);
D[32] = min(D[32],D[34]+D[42]);
D[33] = min(D[33],D[34]+D[43]);
D[34] = min(D[34],D[34]+D[44]);
D[35] = min(D[35],D[34]+D[45]);
D[36] = min(D[36],D[34]+D[46]);
D[37] = min(D[37],D[34]+D[47]);
D[38] = min(D[38],D[34]+D[48]);
D[39] = min(D[39],D[34]+D[49]);
D[40] = min(D[40],D[44]+D[40]);
D[41] = min(D[41],D[44]+D[41]);
D[42] = min(D[42],D[44]+D[42]);
D[43] = min(D[43],D[44]+D[43]);
D[44] = min(D[44],D[44]+D[44]);
D[45] = min(D[45],D[44]+D[45]);
D[46] = min(D[46],D[44]+D[46]);
D[47] = min(D[47],D[44]+D[47]);
D[48] = min(D[48],D[44]+D[48]);
D[49] = min(D[49],D[44]+D[49]);
D[50] = min(D[50],D[54]+D[40]);
D[51] = min(D[51],D[54]+D[41]);
D[52] = min(D[52],D[54]+D[42]);
D[53] = min(D[53],D[54]+D[43]);
D[54] = min(D[54],D[54]+D[44]);
D[55] = min(D[55],D[54]+D[45]);
D[56] = min(D[56],D[54]+D[46]);
D[57] = min(D[57],D[54]+D[47]);
D[58] = min(D[58],D[54]+D[48]);
D[59] = min(D[59],D[54]+D[49]);
D[60] = min(D[60],D[64]+D[40]);
D[61] = min(D[61],D[64]+D[41]);
D[62] = min(D[62],D[64]+D[42]);
D[63] = min(D[63],D[64]+D[43]);
D[64] = min(D[64],D[64]+D[44]);
D[65] = min(D[65],D[64]+D[45]);
D[66] = min(D[66],D[64]+D[46]);
D[67] = min(D[67],D[64]+D[47]);
D[68] = min(D[68],D[64]+D[48]);
D[69] = min(D[69],D[64]+D[49]);
D[70] = min(D[70],D[74]+D[40]);
D[71] = min(D[71],D[74]+D[41]);
D[72] = min(D[72],D[74]+D[42]);
D[73] = min(D[73],D[74]+D[43]);
D[74] = min(D[74],D[74]+D[44]);
D[75] = min(D[75],D[74]+D[45]);
D[76] = min(D[76],D[74]+D[46]);
D[77] = min(D[77],D[74]+D[47]);
D[78] = min(D[78],D[74]+D[48]);
D[79] = min(D[79],D[74]+D[49]);
D[80] = min(D[80],D[84]+D[40]);
D[81] = min(D[81],D[84]+D[41]);
D[82] = min(D[82],D[84]+D[42]);
D[83] = min(D[83],D[84]+D[43]);
D[84] = min(D[84],D[84]+D[44]);
D[85] = min(D[85],D[84]+D[45]);
D[86] = min(D[86],D[84]+D[46]);
D[87] = min(D[87],D[84]+D[47]);
D[88] = min(D[88],D[84]+D[48]);
D[89] = min(D[89],D[84]+D[49]);
D[90] = min(D[90],D[94]+D[40]);
D[91] = min(D[91],D[94]+D[41]);
D[92] = min(D[92],D[94]+D[42]);
D[93] = min(D[93],D[94]+D[43]);
D[94] = min(D[94],D[94]+D[44]);
D[95] = min(D[95],D[94]+D[45]);
D[96] = min(D[96],D[94]+D[46]);
D[97] = min(D[97],D[94]+D[47]);
D[98] = min(D[98],D[94]+D[48]);
D[99] = min(D[99],D[94]+D[49]);
D[0] = min(D[0],D[5]+D[50]);
D[1] = min(D[1],D[5]+D[51]);
D[2] = min(D[2],D[5]+D[52]);
D[3] = min(D[3],D[5]+D[53]);
D[4] = min(D[4],D[5]+D[54]);
D[5] = min(D[5],D[5]+D[55]);
D[6] = min(D[6],D[5]+D[56]);
D[7] = min(D[7],D[5]+D[57]);
D[8] = min(D[8],D[5]+D[58]);
D[9] = min(D[9],D[5]+D[59]);
D[10] = min(D[10],D[15]+D[50]);
D[11] = min(D[11],D[15]+D[51]);
D[12] = min(D[12],D[15]+D[52]);
D[13] = min(D[13],D[15]+D[53]);
D[14] = min(D[14],D[15]+D[54]);
D[15] = min(D[15],D[15]+D[55]);
D[16] = min(D[16],D[15]+D[56]);
D[17] = min(D[17],D[15]+D[57]);
D[18] = min(D[18],D[15]+D[58]);
D[19] = min(D[19],D[15]+D[59]);
D[20] = min(D[20],D[25]+D[50]);
D[21] = min(D[21],D[25]+D[51]);
D[22] = min(D[22],D[25]+D[52]);
D[23] = min(D[23],D[25]+D[53]);
D[24] = min(D[24],D[25]+D[54]);
D[25] = min(D[25],D[25]+D[55]);
D[26] = min(D[26],D[25]+D[56]);
D[27] = min(D[27],D[25]+D[57]);
D[28] = min(D[28],D[25]+D[58]);
D[29] = min(D[29],D[25]+D[59]);
D[30] = min(D[30],D[35]+D[50]);
D[31] = min(D[31],D[35]+D[51]);
D[32] = min(D[32],D[35]+D[52]);
D[33] = min(D[33],D[35]+D[53]);
D[34] = min(D[34],D[35]+D[54]);
D[35] = min(D[35],D[35]+D[55]);
D[36] = min(D[36],D[35]+D[56]);
D[37] = min(D[37],D[35]+D[57]);
D[38] = min(D[38],D[35]+D[58]);
D[39] = min(D[39],D[35]+D[59]);
D[40] = min(D[40],D[45]+D[50]);
D[41] = min(D[41],D[45]+D[51]);
D[42] = min(D[42],D[45]+D[52]);
D[43] = min(D[43],D[45]+D[53]);
D[44] = min(D[44],D[45]+D[54]);
D[45] = min(D[45],D[45]+D[55]);
D[46] = min(D[46],D[45]+D[56]);
D[47] = min(D[47],D[45]+D[57]);
D[48] = min(D[48],D[45]+D[58]);
D[49] = min(D[49],D[45]+D[59]);
D[50] = min(D[50],D[55]+D[50]);
D[51] = min(D[51],D[55]+D[51]);
D[52] = min(D[52],D[55]+D[52]);
D[53] = min(D[53],D[55]+D[53]);
D[54] = min(D[54],D[55]+D[54]);
D[55] = min(D[55],D[55]+D[55]);
D[56] = min(D[56],D[55]+D[56]);
D[57] = min(D[57],D[55]+D[57]);
D[58] = min(D[58],D[55]+D[58]);
D[59] = min(D[59],D[55]+D[59]);
D[60] = min(D[60],D[65]+D[50]);
D[61] = min(D[61],D[65]+D[51]);
D[62] = min(D[62],D[65]+D[52]);
D[63] = min(D[63],D[65]+D[53]);
D[64] = min(D[64],D[65]+D[54]);
D[65] = min(D[65],D[65]+D[55]);
D[66] = min(D[66],D[65]+D[56]);
D[67] = min(D[67],D[65]+D[57]);
D[68] = min(D[68],D[65]+D[58]);
D[69] = min(D[69],D[65]+D[59]);
D[70] = min(D[70],D[75]+D[50]);
D[71] = min(D[71],D[75]+D[51]);
D[72] = min(D[72],D[75]+D[52]);
D[73] = min(D[73],D[75]+D[53]);
D[74] = min(D[74],D[75]+D[54]);
D[75] = min(D[75],D[75]+D[55]);
D[76] = min(D[76],D[75]+D[56]);
D[77] = min(D[77],D[75]+D[57]);
D[78] = min(D[78],D[75]+D[58]);
D[79] = min(D[79],D[75]+D[59]);
D[80] = min(D[80],D[85]+D[50]);
D[81] = min(D[81],D[85]+D[51]);
D[82] = min(D[82],D[85]+D[52]);
D[83] = min(D[83],D[85]+D[53]);
D[84] = min(D[84],D[85]+D[54]);
D[85] = min(D[85],D[85]+D[55]);
D[86] = min(D[86],D[85]+D[56]);
D[87] = min(D[87],D[85]+D[57]);
D[88] = min(D[88],D[85]+D[58]);
D[89] = min(D[89],D[85]+D[59]);
D[90] = min(D[90],D[95]+D[50]);
D[91] = min(D[91],D[95]+D[51]);
D[92] = min(D[92],D[95]+D[52]);
D[93] = min(D[93],D[95]+D[53]);
D[94] = min(D[94],D[95]+D[54]);
D[95] = min(D[95],D[95]+D[55]);
D[96] = min(D[96],D[95]+D[56]);
D[97] = min(D[97],D[95]+D[57]);
D[98] = min(D[98],D[95]+D[58]);
D[99] = min(D[99],D[95]+D[59]);
D[0] = min(D[0],D[6]+D[60]);
D[1] = min(D[1],D[6]+D[61]);
D[2] = min(D[2],D[6]+D[62]);
D[3] = min(D[3],D[6]+D[63]);
D[4] = min(D[4],D[6]+D[64]);
D[5] = min(D[5],D[6]+D[65]);
D[6] = min(D[6],D[6]+D[66]);
D[7] = min(D[7],D[6]+D[67]);
D[8] = min(D[8],D[6]+D[68]);
D[9] = min(D[9],D[6]+D[69]);
D[10] = min(D[10],D[16]+D[60]);
D[11] = min(D[11],D[16]+D[61]);
D[12] = min(D[12],D[16]+D[62]);
D[13] = min(D[13],D[16]+D[63]);
D[14] = min(D[14],D[16]+D[64]);
D[15] = min(D[15],D[16]+D[65]);
D[16] = min(D[16],D[16]+D[66]);
D[17] = min(D[17],D[16]+D[67]);
D[18] = min(D[18],D[16]+D[68]);
D[19] = min(D[19],D[16]+D[69]);
D[20] = min(D[20],D[26]+D[60]);
D[21] = min(D[21],D[26]+D[61]);
D[22] = min(D[22],D[26]+D[62]);
D[23] = min(D[23],D[26]+D[63]);
D[24] = min(D[24],D[26]+D[64]);
D[25] = min(D[25],D[26]+D[65]);
D[26] = min(D[26],D[26]+D[66]);
D[27] = min(D[27],D[26]+D[67]);
D[28] = min(D[28],D[26]+D[68]);
D[29] = min(D[29],D[26]+D[69]);
D[30] = min(D[30],D[36]+D[60]);
D[31] = min(D[31],D[36]+D[61]);
D[32] = min(D[32],D[36]+D[62]);
D[33] = min(D[33],D[36]+D[63]);
D[34] = min(D[34],D[36]+D[64]);
D[35] = min(D[35],D[36]+D[65]);
D[36] = min(D[36],D[36]+D[66]);
D[37] = min(D[37],D[36]+D[67]);
D[38] = min(D[38],D[36]+D[68]);
D[39] = min(D[39],D[36]+D[69]);
D[40] = min(D[40],D[46]+D[60]);
D[41] = min(D[41],D[46]+D[61]);
D[42] = min(D[42],D[46]+D[62]);
D[43] = min(D[43],D[46]+D[63]);
D[44] = min(D[44],D[46]+D[64]);
D[45] = min(D[45],D[46]+D[65]);
D[46] = min(D[46],D[46]+D[66]);
D[47] = min(D[47],D[46]+D[67]);
D[48] = min(D[48],D[46]+D[68]);
D[49] = min(D[49],D[46]+D[69]);
D[50] = min(D[50],D[56]+D[60]);
D[51] = min(D[51],D[56]+D[61]);
D[52] = min(D[52],D[56]+D[62]);
D[53] = min(D[53],D[56]+D[63]);
D[54] = min(D[54],D[56]+D[64]);
D[55] = min(D[55],D[56]+D[65]);
D[56] = min(D[56],D[56]+D[66]);
D[57] = min(D[57],D[56]+D[67]);
D[58] = min(D[58],D[56]+D[68]);
D[59] = min(D[59],D[56]+D[69]);
D[60] = min(D[60],D[66]+D[60]);
D[61] = min(D[61],D[66]+D[61]);
D[62] = min(D[62],D[66]+D[62]);
D[63] = min(D[63],D[66]+D[63]);
D[64] = min(D[64],D[66]+D[64]);
D[65] = min(D[65],D[66]+D[65]);
D[66] = min(D[66],D[66]+D[66]);
D[67] = min(D[67],D[66]+D[67]);
D[68] = min(D[68],D[66]+D[68]);
D[69] = min(D[69],D[66]+D[69]);
D[70] = min(D[70],D[76]+D[60]);
D[71] = min(D[71],D[76]+D[61]);
D[72] = min(D[72],D[76]+D[62]);
D[73] = min(D[73],D[76]+D[63]);
D[74] = min(D[74],D[76]+D[64]);
D[75] = min(D[75],D[76]+D[65]);
D[76] = min(D[76],D[76]+D[66]);
D[77] = min(D[77],D[76]+D[67]);
D[78] = min(D[78],D[76]+D[68]);
D[79] = min(D[79],D[76]+D[69]);
D[80] = min(D[80],D[86]+D[60]);
D[81] = min(D[81],D[86]+D[61]);
D[82] = min(D[82],D[86]+D[62]);
D[83] = min(D[83],D[86]+D[63]);
D[84] = min(D[84],D[86]+D[64]);
D[85] = min(D[85],D[86]+D[65]);
D[86] = min(D[86],D[86]+D[66]);
D[87] = min(D[87],D[86]+D[67]);
D[88] = min(D[88],D[86]+D[68]);
D[89] = min(D[89],D[86]+D[69]);
D[90] = min(D[90],D[96]+D[60]);
D[91] = min(D[91],D[96]+D[61]);
D[92] = min(D[92],D[96]+D[62]);
D[93] = min(D[93],D[96]+D[63]);
D[94] = min(D[94],D[96]+D[64]);
D[95] = min(D[95],D[96]+D[65]);
D[96] = min(D[96],D[96]+D[66]);
D[97] = min(D[97],D[96]+D[67]);
D[98] = min(D[98],D[96]+D[68]);
D[99] = min(D[99],D[96]+D[69]);
D[0] = min(D[0],D[7]+D[70]);
D[1] = min(D[1],D[7]+D[71]);
D[2] = min(D[2],D[7]+D[72]);
D[3] = min(D[3],D[7]+D[73]);
D[4] = min(D[4],D[7]+D[74]);
D[5] = min(D[5],D[7]+D[75]);
D[6] = min(D[6],D[7]+D[76]);
D[7] = min(D[7],D[7]+D[77]);
D[8] = min(D[8],D[7]+D[78]);
D[9] = min(D[9],D[7]+D[79]);
D[10] = min(D[10],D[17]+D[70]);
D[11] = min(D[11],D[17]+D[71]);
D[12] = min(D[12],D[17]+D[72]);
D[13] = min(D[13],D[17]+D[73]);
D[14] = min(D[14],D[17]+D[74]);
D[15] = min(D[15],D[17]+D[75]);
D[16] = min(D[16],D[17]+D[76]);
D[17] = min(D[17],D[17]+D[77]);
D[18] = min(D[18],D[17]+D[78]);
D[19] = min(D[19],D[17]+D[79]);
D[20] = min(D[20],D[27]+D[70]);
D[21] = min(D[21],D[27]+D[71]);
D[22] = min(D[22],D[27]+D[72]);
D[23] = min(D[23],D[27]+D[73]);
D[24] = min(D[24],D[27]+D[74]);
D[25] = min(D[25],D[27]+D[75]);
D[26] = min(D[26],D[27]+D[76]);
D[27] = min(D[27],D[27]+D[77]);
D[28] = min(D[28],D[27]+D[78]);
D[29] = min(D[29],D[27]+D[79]);
D[30] = min(D[30],D[37]+D[70]);
D[31] = min(D[31],D[37]+D[71]);
D[32] = min(D[32],D[37]+D[72]);
D[33] = min(D[33],D[37]+D[73]);
D[34] = min(D[34],D[37]+D[74]);
D[35] = min(D[35],D[37]+D[75]);
D[36] = min(D[36],D[37]+D[76]);
D[37] = min(D[37],D[37]+D[77]);
D[38] = min(D[38],D[37]+D[78]);
D[39] = min(D[39],D[37]+D[79]);
D[40] = min(D[40],D[47]+D[70]);
D[41] = min(D[41],D[47]+D[71]);
D[42] = min(D[42],D[47]+D[72]);
D[43] = min(D[43],D[47]+D[73]);
D[44] = min(D[44],D[47]+D[74]);
D[45] = min(D[45],D[47]+D[75]);
D[46] = min(D[46],D[47]+D[76]);
D[47] = min(D[47],D[47]+D[77]);
D[48] = min(D[48],D[47]+D[78]);
D[49] = min(D[49],D[47]+D[79]);
D[50] = min(D[50],D[57]+D[70]);
D[51] = min(D[51],D[57]+D[71]);
D[52] = min(D[52],D[57]+D[72]);
D[53] = min(D[53],D[57]+D[73]);
D[54] = min(D[54],D[57]+D[74]);
D[55] = min(D[55],D[57]+D[75]);
D[56] = min(D[56],D[57]+D[76]);
D[57] = min(D[57],D[57]+D[77]);
D[58] = min(D[58],D[57]+D[78]);
D[59] = min(D[59],D[57]+D[79]);
D[60] = min(D[60],D[67]+D[70]);
D[61] = min(D[61],D[67]+D[71]);
D[62] = min(D[62],D[67]+D[72]);
D[63] = min(D[63],D[67]+D[73]);
D[64] = min(D[64],D[67]+D[74]);
D[65] = min(D[65],D[67]+D[75]);
D[66] = min(D[66],D[67]+D[76]);
D[67] = min(D[67],D[67]+D[77]);
D[68] = min(D[68],D[67]+D[78]);
D[69] = min(D[69],D[67]+D[79]);
D[70] = min(D[70],D[77]+D[70]);
D[71] = min(D[71],D[77]+D[71]);
D[72] = min(D[72],D[77]+D[72]);
D[73] = min(D[73],D[77]+D[73]);
D[74] = min(D[74],D[77]+D[74]);
D[75] = min(D[75],D[77]+D[75]);
D[76] = min(D[76],D[77]+D[76]);
D[77] = min(D[77],D[77]+D[77]);
D[78] = min(D[78],D[77]+D[78]);
D[79] = min(D[79],D[77]+D[79]);
D[80] = min(D[80],D[87]+D[70]);
D[81] = min(D[81],D[87]+D[71]);
D[82] = min(D[82],D[87]+D[72]);
D[83] = min(D[83],D[87]+D[73]);
D[84] = min(D[84],D[87]+D[74]);
D[85] = min(D[85],D[87]+D[75]);
D[86] = min(D[86],D[87]+D[76]);
D[87] = min(D[87],D[87]+D[77]);
D[88] = min(D[88],D[87]+D[78]);
D[89] = min(D[89],D[87]+D[79]);
D[90] = min(D[90],D[97]+D[70]);
D[91] = min(D[91],D[97]+D[71]);
D[92] = min(D[92],D[97]+D[72]);
D[93] = min(D[93],D[97]+D[73]);
D[94] = min(D[94],D[97]+D[74]);
D[95] = min(D[95],D[97]+D[75]);
D[96] = min(D[96],D[97]+D[76]);
D[97] = min(D[97],D[97]+D[77]);
D[98] = min(D[98],D[97]+D[78]);
D[99] = min(D[99],D[97]+D[79]);
D[0] = min(D[0],D[8]+D[80]);
D[1] = min(D[1],D[8]+D[81]);
D[2] = min(D[2],D[8]+D[82]);
D[3] = min(D[3],D[8]+D[83]);
D[4] = min(D[4],D[8]+D[84]);
D[5] = min(D[5],D[8]+D[85]);
D[6] = min(D[6],D[8]+D[86]);
D[7] = min(D[7],D[8]+D[87]);
D[8] = min(D[8],D[8]+D[88]);
D[9] = min(D[9],D[8]+D[89]);
D[10] = min(D[10],D[18]+D[80]);
D[11] = min(D[11],D[18]+D[81]);
D[12] = min(D[12],D[18]+D[82]);
D[13] = min(D[13],D[18]+D[83]);
D[14] = min(D[14],D[18]+D[84]);
D[15] = min(D[15],D[18]+D[85]);
D[16] = min(D[16],D[18]+D[86]);
D[17] = min(D[17],D[18]+D[87]);
D[18] = min(D[18],D[18]+D[88]);
D[19] = min(D[19],D[18]+D[89]);
D[20] = min(D[20],D[28]+D[80]);
D[21] = min(D[21],D[28]+D[81]);
D[22] = min(D[22],D[28]+D[82]);
D[23] = min(D[23],D[28]+D[83]);
D[24] = min(D[24],D[28]+D[84]);
D[25] = min(D[25],D[28]+D[85]);
D[26] = min(D[26],D[28]+D[86]);
D[27] = min(D[27],D[28]+D[87]);
D[28] = min(D[28],D[28]+D[88]);
D[29] = min(D[29],D[28]+D[89]);
D[30] = min(D[30],D[38]+D[80]);
D[31] = min(D[31],D[38]+D[81]);
D[32] = min(D[32],D[38]+D[82]);
D[33] = min(D[33],D[38]+D[83]);
D[34] = min(D[34],D[38]+D[84]);
D[35] = min(D[35],D[38]+D[85]);
D[36] = min(D[36],D[38]+D[86]);
D[37] = min(D[37],D[38]+D[87]);
D[38] = min(D[38],D[38]+D[88]);
D[39] = min(D[39],D[38]+D[89]);
D[40] = min(D[40],D[48]+D[80]);
D[41] = min(D[41],D[48]+D[81]);
D[42] = min(D[42],D[48]+D[82]);
D[43] = min(D[43],D[48]+D[83]);
D[44] = min(D[44],D[48]+D[84]);
D[45] = min(D[45],D[48]+D[85]);
D[46] = min(D[46],D[48]+D[86]);
D[47] = min(D[47],D[48]+D[87]);
D[48] = min(D[48],D[48]+D[88]);
D[49] = min(D[49],D[48]+D[89]);
D[50] = min(D[50],D[58]+D[80]);
D[51] = min(D[51],D[58]+D[81]);
D[52] = min(D[52],D[58]+D[82]);
D[53] = min(D[53],D[58]+D[83]);
D[54] = min(D[54],D[58]+D[84]);
D[55] = min(D[55],D[58]+D[85]);
D[56] = min(D[56],D[58]+D[86]);
D[57] = min(D[57],D[58]+D[87]);
D[58] = min(D[58],D[58]+D[88]);
D[59] = min(D[59],D[58]+D[89]);
D[60] = min(D[60],D[68]+D[80]);
D[61] = min(D[61],D[68]+D[81]);
D[62] = min(D[62],D[68]+D[82]);
D[63] = min(D[63],D[68]+D[83]);
D[64] = min(D[64],D[68]+D[84]);
D[65] = min(D[65],D[68]+D[85]);
D[66] = min(D[66],D[68]+D[86]);
D[67] = min(D[67],D[68]+D[87]);
D[68] = min(D[68],D[68]+D[88]);
D[69] = min(D[69],D[68]+D[89]);
D[70] = min(D[70],D[78]+D[80]);
D[71] = min(D[71],D[78]+D[81]);
D[72] = min(D[72],D[78]+D[82]);
D[73] = min(D[73],D[78]+D[83]);
D[74] = min(D[74],D[78]+D[84]);
D[75] = min(D[75],D[78]+D[85]);
D[76] = min(D[76],D[78]+D[86]);
D[77] = min(D[77],D[78]+D[87]);
D[78] = min(D[78],D[78]+D[88]);
D[79] = min(D[79],D[78]+D[89]);
D[80] = min(D[80],D[88]+D[80]);
D[81] = min(D[81],D[88]+D[81]);
D[82] = min(D[82],D[88]+D[82]);
D[83] = min(D[83],D[88]+D[83]);
D[84] = min(D[84],D[88]+D[84]);
D[85] = min(D[85],D[88]+D[85]);
D[86] = min(D[86],D[88]+D[86]);
D[87] = min(D[87],D[88]+D[87]);
D[88] = min(D[88],D[88]+D[88]);
D[89] = min(D[89],D[88]+D[89]);
D[90] = min(D[90],D[98]+D[80]);
D[91] = min(D[91],D[98]+D[81]);
D[92] = min(D[92],D[98]+D[82]);
D[93] = min(D[93],D[98]+D[83]);
D[94] = min(D[94],D[98]+D[84]);
D[95] = min(D[95],D[98]+D[85]);
D[96] = min(D[96],D[98]+D[86]);
D[97] = min(D[97],D[98]+D[87]);
D[98] = min(D[98],D[98]+D[88]);
D[99] = min(D[99],D[98]+D[89]);
D[0] = min(D[0],D[9]+D[90]);
D[1] = min(D[1],D[9]+D[91]);
D[2] = min(D[2],D[9]+D[92]);
D[3] = min(D[3],D[9]+D[93]);
D[4] = min(D[4],D[9]+D[94]);
D[5] = min(D[5],D[9]+D[95]);
D[6] = min(D[6],D[9]+D[96]);
D[7] = min(D[7],D[9]+D[97]);
D[8] = min(D[8],D[9]+D[98]);
D[9] = min(D[9],D[9]+D[99]);
D[10] = min(D[10],D[19]+D[90]);
D[11] = min(D[11],D[19]+D[91]);
D[12] = min(D[12],D[19]+D[92]);
D[13] = min(D[13],D[19]+D[93]);
D[14] = min(D[14],D[19]+D[94]);
D[15] = min(D[15],D[19]+D[95]);
D[16] = min(D[16],D[19]+D[96]);
D[17] = min(D[17],D[19]+D[97]);
D[18] = min(D[18],D[19]+D[98]);
D[19] = min(D[19],D[19]+D[99]);
D[20] = min(D[20],D[29]+D[90]);
D[21] = min(D[21],D[29]+D[91]);
D[22] = min(D[22],D[29]+D[92]);
D[23] = min(D[23],D[29]+D[93]);
D[24] = min(D[24],D[29]+D[94]);
D[25] = min(D[25],D[29]+D[95]);
D[26] = min(D[26],D[29]+D[96]);
D[27] = min(D[27],D[29]+D[97]);
D[28] = min(D[28],D[29]+D[98]);
D[29] = min(D[29],D[29]+D[99]);
D[30] = min(D[30],D[39]+D[90]);
D[31] = min(D[31],D[39]+D[91]);
D[32] = min(D[32],D[39]+D[92]);
D[33] = min(D[33],D[39]+D[93]);
D[34] = min(D[34],D[39]+D[94]);
D[35] = min(D[35],D[39]+D[95]);
D[36] = min(D[36],D[39]+D[96]);
D[37] = min(D[37],D[39]+D[97]);
D[38] = min(D[38],D[39]+D[98]);
D[39] = min(D[39],D[39]+D[99]);
D[40] = min(D[40],D[49]+D[90]);
D[41] = min(D[41],D[49]+D[91]);
D[42] = min(D[42],D[49]+D[92]);
D[43] = min(D[43],D[49]+D[93]);
D[44] = min(D[44],D[49]+D[94]);
D[45] = min(D[45],D[49]+D[95]);
D[46] = min(D[46],D[49]+D[96]);
D[47] = min(D[47],D[49]+D[97]);
D[48] = min(D[48],D[49]+D[98]);
D[49] = min(D[49],D[49]+D[99]);
D[50] = min(D[50],D[59]+D[90]);
D[51] = min(D[51],D[59]+D[91]);
D[52] = min(D[52],D[59]+D[92]);
D[53] = min(D[53],D[59]+D[93]);
D[54] = min(D[54],D[59]+D[94]);
D[55] = min(D[55],D[59]+D[95]);
D[56] = min(D[56],D[59]+D[96]);
D[57] = min(D[57],D[59]+D[97]);
D[58] = min(D[58],D[59]+D[98]);
D[59] = min(D[59],D[59]+D[99]);
D[60] = min(D[60],D[69]+D[90]);
D[61] = min(D[61],D[69]+D[91]);
D[62] = min(D[62],D[69]+D[92]);
D[63] = min(D[63],D[69]+D[93]);
D[64] = min(D[64],D[69]+D[94]);
D[65] = min(D[65],D[69]+D[95]);
D[66] = min(D[66],D[69]+D[96]);
D[67] = min(D[67],D[69]+D[97]);
D[68] = min(D[68],D[69]+D[98]);
D[69] = min(D[69],D[69]+D[99]);
D[70] = min(D[70],D[79]+D[90]);
D[71] = min(D[71],D[79]+D[91]);
D[72] = min(D[72],D[79]+D[92]);
D[73] = min(D[73],D[79]+D[93]);
D[74] = min(D[74],D[79]+D[94]);
D[75] = min(D[75],D[79]+D[95]);
D[76] = min(D[76],D[79]+D[96]);
D[77] = min(D[77],D[79]+D[97]);
D[78] = min(D[78],D[79]+D[98]);
D[79] = min(D[79],D[79]+D[99]);
D[80] = min(D[80],D[89]+D[90]);
D[81] = min(D[81],D[89]+D[91]);
D[82] = min(D[82],D[89]+D[92]);
D[83] = min(D[83],D[89]+D[93]);
D[84] = min(D[84],D[89]+D[94]);
D[85] = min(D[85],D[89]+D[95]);
D[86] = min(D[86],D[89]+D[96]);
D[87] = min(D[87],D[89]+D[97]);
D[88] = min(D[88],D[89]+D[98]);
D[89] = min(D[89],D[89]+D[99]);
D[90] = min(D[90],D[99]+D[90]);
D[91] = min(D[91],D[99]+D[91]);
D[92] = min(D[92],D[99]+D[92]);
D[93] = min(D[93],D[99]+D[93]);
D[94] = min(D[94],D[99]+D[94]);
D[95] = min(D[95],D[99]+D[95]);
D[96] = min(D[96],D[99]+D[96]);
D[97] = min(D[97],D[99]+D[97]);
D[98] = min(D[98],D[99]+D[98]);
D[99] = min(D[99],D[99]+D[99]);
}

int main ()
{
  DRI(N);

D[0] = 1000000007;
D[1] = 1000000007;
D[2] = 1000000007;
D[3] = 1000000007;
D[4] = 1000000007;
D[5] = 1000000007;
D[6] = 1000000007;
D[7] = 1000000007;
D[8] = 1000000007;
D[9] = 1000000007;
D[10] = 1000000007;
D[11] = 1000000007;
D[12] = 1000000007;
D[13] = 1000000007;
D[14] = 1000000007;
D[15] = 1000000007;
D[16] = 1000000007;
D[17] = 1000000007;
D[18] = 1000000007;
D[19] = 1000000007;
D[20] = 1000000007;
D[21] = 1000000007;
D[22] = 1000000007;
D[23] = 1000000007;
D[24] = 1000000007;
D[25] = 1000000007;
D[26] = 1000000007;
D[27] = 1000000007;
D[28] = 1000000007;
D[29] = 1000000007;
D[30] = 1000000007;
D[31] = 1000000007;
D[32] = 1000000007;
D[33] = 1000000007;
D[34] = 1000000007;
D[35] = 1000000007;
D[36] = 1000000007;
D[37] = 1000000007;
D[38] = 1000000007;
D[39] = 1000000007;
D[40] = 1000000007;
D[41] = 1000000007;
D[42] = 1000000007;
D[43] = 1000000007;
D[44] = 1000000007;
D[45] = 1000000007;
D[46] = 1000000007;
D[47] = 1000000007;
D[48] = 1000000007;
D[49] = 1000000007;
D[50] = 1000000007;
D[51] = 1000000007;
D[52] = 1000000007;
D[53] = 1000000007;
D[54] = 1000000007;
D[55] = 1000000007;
D[56] = 1000000007;
D[57] = 1000000007;
D[58] = 1000000007;
D[59] = 1000000007;
D[60] = 1000000007;
D[61] = 1000000007;
D[62] = 1000000007;
D[63] = 1000000007;
D[64] = 1000000007;
D[65] = 1000000007;
D[66] = 1000000007;
D[67] = 1000000007;
D[68] = 1000000007;
D[69] = 1000000007;
D[70] = 1000000007;
D[71] = 1000000007;
D[72] = 1000000007;
D[73] = 1000000007;
D[74] = 1000000007;
D[75] = 1000000007;
D[76] = 1000000007;
D[77] = 1000000007;
D[78] = 1000000007;
D[79] = 1000000007;
D[80] = 1000000007;
D[81] = 1000000007;
D[82] = 1000000007;
D[83] = 1000000007;
D[84] = 1000000007;
D[85] = 1000000007;
D[86] = 1000000007;
D[87] = 1000000007;
D[88] = 1000000007;
D[89] = 1000000007;
D[90] = 1000000007;
D[91] = 1000000007;
D[92] = 1000000007;
D[93] = 1000000007;
D[94] = 1000000007;
D[95] = 1000000007;
D[96] = 1000000007;
D[97] = 1000000007;
D[98] = 1000000007;
D[99] = 1000000007;
scanf("%d",&D[(0/N)*10+(0%N)]);
scanf("%d",&D[(1/N)*10+(1%N)]);
scanf("%d",&D[(2/N)*10+(2%N)]);
scanf("%d",&D[(3/N)*10+(3%N)]);
scanf("%d",&D[(4/N)*10+(4%N)]);
scanf("%d",&D[(5/N)*10+(5%N)]);
scanf("%d",&D[(6/N)*10+(6%N)]);
scanf("%d",&D[(7/N)*10+(7%N)]);
scanf("%d",&D[(8/N)*10+(8%N)]);
scanf("%d",&D[(9/N)*10+(9%N)]);
scanf("%d",&D[(10/N)*10+(10%N)]);
scanf("%d",&D[(11/N)*10+(11%N)]);
scanf("%d",&D[(12/N)*10+(12%N)]);
scanf("%d",&D[(13/N)*10+(13%N)]);
scanf("%d",&D[(14/N)*10+(14%N)]);
scanf("%d",&D[(15/N)*10+(15%N)]);
scanf("%d",&D[(16/N)*10+(16%N)]);
scanf("%d",&D[(17/N)*10+(17%N)]);
scanf("%d",&D[(18/N)*10+(18%N)]);
scanf("%d",&D[(19/N)*10+(19%N)]);
scanf("%d",&D[(20/N)*10+(20%N)]);
scanf("%d",&D[(21/N)*10+(21%N)]);
scanf("%d",&D[(22/N)*10+(22%N)]);
scanf("%d",&D[(23/N)*10+(23%N)]);
scanf("%d",&D[(24/N)*10+(24%N)]);
scanf("%d",&D[(25/N)*10+(25%N)]);
scanf("%d",&D[(26/N)*10+(26%N)]);
scanf("%d",&D[(27/N)*10+(27%N)]);
scanf("%d",&D[(28/N)*10+(28%N)]);
scanf("%d",&D[(29/N)*10+(29%N)]);
scanf("%d",&D[(30/N)*10+(30%N)]);
scanf("%d",&D[(31/N)*10+(31%N)]);
scanf("%d",&D[(32/N)*10+(32%N)]);
scanf("%d",&D[(33/N)*10+(33%N)]);
scanf("%d",&D[(34/N)*10+(34%N)]);
scanf("%d",&D[(35/N)*10+(35%N)]);
scanf("%d",&D[(36/N)*10+(36%N)]);
scanf("%d",&D[(37/N)*10+(37%N)]);
scanf("%d",&D[(38/N)*10+(38%N)]);
scanf("%d",&D[(39/N)*10+(39%N)]);
scanf("%d",&D[(40/N)*10+(40%N)]);
scanf("%d",&D[(41/N)*10+(41%N)]);
scanf("%d",&D[(42/N)*10+(42%N)]);
scanf("%d",&D[(43/N)*10+(43%N)]);
scanf("%d",&D[(44/N)*10+(44%N)]);
scanf("%d",&D[(45/N)*10+(45%N)]);
scanf("%d",&D[(46/N)*10+(46%N)]);
scanf("%d",&D[(47/N)*10+(47%N)]);
scanf("%d",&D[(48/N)*10+(48%N)]);
scanf("%d",&D[(49/N)*10+(49%N)]);
scanf("%d",&D[(50/N)*10+(50%N)]);
scanf("%d",&D[(51/N)*10+(51%N)]);
scanf("%d",&D[(52/N)*10+(52%N)]);
scanf("%d",&D[(53/N)*10+(53%N)]);
scanf("%d",&D[(54/N)*10+(54%N)]);
scanf("%d",&D[(55/N)*10+(55%N)]);
scanf("%d",&D[(56/N)*10+(56%N)]);
scanf("%d",&D[(57/N)*10+(57%N)]);
scanf("%d",&D[(58/N)*10+(58%N)]);
scanf("%d",&D[(59/N)*10+(59%N)]);
scanf("%d",&D[(60/N)*10+(60%N)]);
scanf("%d",&D[(61/N)*10+(61%N)]);
scanf("%d",&D[(62/N)*10+(62%N)]);
scanf("%d",&D[(63/N)*10+(63%N)]);
scanf("%d",&D[(64/N)*10+(64%N)]);
scanf("%d",&D[(65/N)*10+(65%N)]);
scanf("%d",&D[(66/N)*10+(66%N)]);
scanf("%d",&D[(67/N)*10+(67%N)]);
scanf("%d",&D[(68/N)*10+(68%N)]);
scanf("%d",&D[(69/N)*10+(69%N)]);
scanf("%d",&D[(70/N)*10+(70%N)]);
scanf("%d",&D[(71/N)*10+(71%N)]);
scanf("%d",&D[(72/N)*10+(72%N)]);
scanf("%d",&D[(73/N)*10+(73%N)]);
scanf("%d",&D[(74/N)*10+(74%N)]);
scanf("%d",&D[(75/N)*10+(75%N)]);
scanf("%d",&D[(76/N)*10+(76%N)]);
scanf("%d",&D[(77/N)*10+(77%N)]);
scanf("%d",&D[(78/N)*10+(78%N)]);
scanf("%d",&D[(79/N)*10+(79%N)]);
scanf("%d",&D[(80/N)*10+(80%N)]);
scanf("%d",&D[(81/N)*10+(81%N)]);
scanf("%d",&D[(82/N)*10+(82%N)]);
scanf("%d",&D[(83/N)*10+(83%N)]);
scanf("%d",&D[(84/N)*10+(84%N)]);
scanf("%d",&D[(85/N)*10+(85%N)]);
scanf("%d",&D[(86/N)*10+(86%N)]);
scanf("%d",&D[(87/N)*10+(87%N)]);
scanf("%d",&D[(88/N)*10+(88%N)]);
scanf("%d",&D[(89/N)*10+(89%N)]);
scanf("%d",&D[(90/N)*10+(90%N)]);
scanf("%d",&D[(91/N)*10+(91%N)]);
scanf("%d",&D[(92/N)*10+(92%N)]);
scanf("%d",&D[(93/N)*10+(93%N)]);
scanf("%d",&D[(94/N)*10+(94%N)]);
scanf("%d",&D[(95/N)*10+(95%N)]);
scanf("%d",&D[(96/N)*10+(96%N)]);
scanf("%d",&D[(97/N)*10+(97%N)]);
scanf("%d",&D[(98/N)*10+(98%N)]);
scanf("%d",&D[(99/N)*10+(99%N)]);

  FW();
  int res = 0;

res = max(res,D[1]%1000000007);
res = max(res,D[2]%1000000007);
res = max(res,D[3]%1000000007);
res = max(res,D[4]%1000000007);
res = max(res,D[5]%1000000007);
res = max(res,D[6]%1000000007);
res = max(res,D[7]%1000000007);
res = max(res,D[8]%1000000007);
res = max(res,D[9]%1000000007);
res = max(res,D[10]%1000000007);
res = max(res,D[12]%1000000007);
res = max(res,D[13]%1000000007);
res = max(res,D[14]%1000000007);
res = max(res,D[15]%1000000007);
res = max(res,D[16]%1000000007);
res = max(res,D[17]%1000000007);
res = max(res,D[18]%1000000007);
res = max(res,D[19]%1000000007);
res = max(res,D[20]%1000000007);
res = max(res,D[21]%1000000007);
res = max(res,D[23]%1000000007);
res = max(res,D[24]%1000000007);
res = max(res,D[25]%1000000007);
res = max(res,D[26]%1000000007);
res = max(res,D[27]%1000000007);
res = max(res,D[28]%1000000007);
res = max(res,D[29]%1000000007);
res = max(res,D[30]%1000000007);
res = max(res,D[31]%1000000007);
res = max(res,D[32]%1000000007);
res = max(res,D[34]%1000000007);
res = max(res,D[35]%1000000007);
res = max(res,D[36]%1000000007);
res = max(res,D[37]%1000000007);
res = max(res,D[38]%1000000007);
res = max(res,D[39]%1000000007);
res = max(res,D[40]%1000000007);
res = max(res,D[41]%1000000007);
res = max(res,D[42]%1000000007);
res = max(res,D[43]%1000000007);
res = max(res,D[45]%1000000007);
res = max(res,D[46]%1000000007);
res = max(res,D[47]%1000000007);
res = max(res,D[48]%1000000007);
res = max(res,D[49]%1000000007);
res = max(res,D[50]%1000000007);
res = max(res,D[51]%1000000007);
res = max(res,D[52]%1000000007);
res = max(res,D[53]%1000000007);
res = max(res,D[54]%1000000007);
res = max(res,D[56]%1000000007);
res = max(res,D[57]%1000000007);
res = max(res,D[58]%1000000007);
res = max(res,D[59]%1000000007);
res = max(res,D[60]%1000000007);
res = max(res,D[61]%1000000007);
res = max(res,D[62]%1000000007);
res = max(res,D[63]%1000000007);
res = max(res,D[64]%1000000007);
res = max(res,D[65]%1000000007);
res = max(res,D[67]%1000000007);
res = max(res,D[68]%1000000007);
res = max(res,D[69]%1000000007);
res = max(res,D[70]%1000000007);
res = max(res,D[71]%1000000007);
res = max(res,D[72]%1000000007);
res = max(res,D[73]%1000000007);
res = max(res,D[74]%1000000007);
res = max(res,D[75]%1000000007);
res = max(res,D[76]%1000000007);
res = max(res,D[78]%1000000007);
res = max(res,D[79]%1000000007);
res = max(res,D[80]%1000000007);
res = max(res,D[81]%1000000007);
res = max(res,D[82]%1000000007);
res = max(res,D[83]%1000000007);
res = max(res,D[84]%1000000007);
res = max(res,D[85]%1000000007);
res = max(res,D[86]%1000000007);
res = max(res,D[87]%1000000007);
res = max(res,D[89]%1000000007);
res = max(res,D[90]%1000000007);
res = max(res,D[91]%1000000007);
res = max(res,D[92]%1000000007);
res = max(res,D[93]%1000000007);
res = max(res,D[94]%1000000007);
res = max(res,D[95]%1000000007);
res = max(res,D[96]%1000000007);
res = max(res,D[97]%1000000007);
res = max(res,D[98]%1000000007);

  cout << res << endl;
  return 0;
}

#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

namespace ink {

	inline int read() {
		int w=1,s=0;char c=getchar();
		while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
		while(c>='0'&&c<='9')s=s*10+(c-'0'),c=getchar();
		return s*w;
	}
	#define _ read()
	#define MAXN (int)(1e5+233)
	#define write(a) printf("%d ",a)

}

using namespace ink;

namespace edge {

	int head[MAXN],dis[MAXN],cnt=0,n; bool vis[MAXN];
	struct edge { int to,dis,nexty; }e[MAXN];
	inline void add(int a,int b,int c) {
		e[++cnt].to=b; e[cnt].dis=c;
		e[cnt].nexty=head[a]; head[a]=cnt;
	}
	struct node {
		int dis,pos;
		bool operator < (const node &rhs) const { return rhs.dis<dis; }
	};

}

using namespace edge;

inline void dij(int s) {

	for(int i=1;i<=n;i++) dis[i]=0x7fffffff,vis[i]=false;
	priority_queue<node> q;  q.push((node){0,s}); dis[s]=0;
	while(!q.empty()) {
		node tmp=q.top(); q.pop();
		int x=tmp.pos;
		if(vis[x]) continue; vis[x]=true;
		for(int i=head[x];i;i=e[i].nexty) {
			int y=e[i].to;
			if(dis[y]>dis[x]+e[i].dis) {
				dis[y]=dis[x]+e[i].dis;
				if(!vis[y]) q.push((node){dis[y],y});
			}
		}
	}

}

int main() {

	n=_;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			int a=_;
			if(i==j) continue;
			add(i,j,a);
		}
	}
	int maxn=0;
	for(int i=1;i<=n;i++) {
		dij(i);
		for(int j=1;j<=n;j++) maxn=max(maxn,dis[j]);
	}
	write(maxn);

}

#include <iostream>
#include <vector>
using namespace std;
int top2();
int main() {
  int n;
  cin >> n;
  vector<vector<int> > a(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
      }
    }
  }
  int res = a[0][1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) {
        res = max(res, a[i][j]);
      }
    }
  }
  cout << res << endl;
}

#include <cstdio>
#include <cstring>
#include <functional>

using namespace std;
const int maxn = 105;
const int INF = 0x3F3F3F3F;

int n;
int map[maxn][maxn];
int dis[maxn][maxn];

int read(int i, int j)
{
	return j <= n ? (scanf("%d", &map[i][j]), read(i, ++j)) : 0;
}

int read(int i)
{
	return i <= n ? (read(i, 1), read(++i)) : 0;
}

int work(int i, int j, int k)
{
	return k <= n ? ((dis[i][j] = (dis[i][j] > dis[i][k] + dis[k][j]) ? dis[i][k] + dis[k][j] : dis[i][j]), work(i, j, ++k)) : 0;
}

int work(int i, int j)
{
	return j <= n ? (work(i, j, 1), work(i, ++j)) : 0;
}
int work(int i)
{
	return i <= n ? (work(i, 1), work(++i)) : 0;
}

int ans;

int find(int i, int j)
{
	return j <= n ? ((ans = ((ans < dis[i][j]) ? dis[i][j] : ans)), find(i, ++j)) : 0;
}

int find(int i)
{
	return i <= n ? (find(i, 1), find(++i)) : 0;
}

int preset(int i)
{
	return i <= n ? (dis[i][i] = 0, preset(++i)) : 0;
}
int main()
{
	scanf("%d", &n);

	read(1);
	memcpy(dis, map, sizeof dis);
	preset(1);
	work(1);
	find(1);

	printf("%d\n", ans);
	return 0;
}

/*
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <ctime>
*/
#include <bits/stdc++.h>/*
#define faster_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define file_name(a) (freopen(((string)(a) + ".in").c_str(),"r",stdin), freopen(((string)(a) + ".out").c_str(),"w",stdout))
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define iter(a) __typeof((a).begin())
#define fore(a,b) for(iter(b) a = (b).begin(); a != (b).end(); ++a)
#define all(a) a.begin(), a.end()
#define clr(a,b) memset((a), (b), sizeof(a))
#define getmax(a,b) ((a) > (b) ? (a) : (b))
#define getmin(a,b) ((a) < (b) ? (a) : (b))
#define getmodule(a) ((a) < 0 ? (-a) : (a))
#define pi acos(-1)
#define st first
#define nd second
#define pb push_back
#define mp make_pair

#define MX (int)(3e5+10)
#define MAXN (1 << 8)

#define left_node (cur_node << 1)
#define right_node (left_node | 1)
#define mid ((left + right) >> 1)
#define bit(x,y) ((x >> y) & 1)
*/

using namespace std;

typedef unsigned long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef vector <ll> vl;
typedef vector <pll> vll;
typedef vector <vl> vvl;

namespace Main {

      ll n, a[12][12];
      ll res;

      ll read() {

            ll x;
            cin >> x;
            return x;

      }

      inline void run() {

            cin >> n;

            a[1][1] = 44444;
            a[1][2] = 44444;
            a[1][3] = 44444;
            a[1][4] = 44444;
            a[1][5] = 44444;
            a[1][6] = 44444;
            a[1][7] = 44444;
            a[1][8] = 44444;
            a[1][9] = 44444;
            a[1][10] = 44444;
            a[2][1] = 44444;
            a[2][2] = 44444;
            a[2][3] = 44444;
            a[2][4] = 44444;
            a[2][5] = 44444;
            a[2][6] = 44444;
            a[2][7] = 44444;
            a[2][8] = 44444;
            a[2][9] = 44444;
            a[2][10] = 44444;
            a[3][1] = 44444;
            a[3][2] = 44444;
            a[3][3] = 44444;
            a[3][4] = 44444;
            a[3][5] = 44444;
            a[3][6] = 44444;
            a[3][7] = 44444;
            a[3][8] = 44444;
            a[3][9] = 44444;
            a[3][10] = 44444;
            a[4][1] = 44444;
            a[4][2] = 44444;
            a[4][3] = 44444;
            a[4][4] = 44444;
            a[4][5] = 44444;
            a[4][6] = 44444;
            a[4][7] = 44444;
            a[4][8] = 44444;
            a[4][9] = 44444;
            a[4][10] = 44444;
            a[5][1] = 44444;
            a[5][2] = 44444;
            a[5][3] = 44444;
            a[5][4] = 44444;
            a[5][5] = 44444;
            a[5][6] = 44444;
            a[5][7] = 44444;
            a[5][8] = 44444;
            a[5][9] = 44444;
            a[5][10] = 44444;
            a[6][1] = 44444;
            a[6][2] = 44444;
            a[6][3] = 44444;
            a[6][4] = 44444;
            a[6][5] = 44444;
            a[6][6] = 44444;
            a[6][7] = 44444;
            a[6][8] = 44444;
            a[6][9] = 44444;
            a[6][10] = 44444;
            a[7][1] = 44444;
            a[7][2] = 44444;
            a[7][3] = 44444;
            a[7][4] = 44444;
            a[7][5] = 44444;
            a[7][6] = 44444;
            a[7][7] = 44444;
            a[7][8] = 44444;
            a[7][9] = 44444;
            a[7][10] = 44444;
            a[8][1] = 44444;
            a[8][2] = 44444;
            a[8][3] = 44444;
            a[8][4] = 44444;
            a[8][5] = 44444;
            a[8][6] = 44444;
            a[8][7] = 44444;
            a[8][8] = 44444;
            a[8][9] = 44444;
            a[8][10] = 44444;
            a[9][1] = 44444;
            a[9][2] = 44444;
            a[9][3] = 44444;
            a[9][4] = 44444;
            a[9][5] = 44444;
            a[9][6] = 44444;
            a[9][7] = 44444;
            a[9][8] = 44444;
            a[9][9] = 44444;
            a[9][10] = 44444;
            a[10][1] = 44444;
            a[10][2] = 44444;
            a[10][3] = 44444;
            a[10][4] = 44444;
            a[10][5] = 44444;
            a[10][6] = 44444;
            a[10][7] = 44444;
            a[10][8] = 44444;
            a[10][9] = 44444;
            a[10][10] = 44444;
            ( 1 <= n && 1 <= n ) ? a[1][1] = read() : 0;
            ( 1 <= n && 2 <= n ) ? a[1][2] = read() : 0;
            ( 1 <= n && 3 <= n ) ? a[1][3] = read() : 0;
            ( 1 <= n && 4 <= n ) ? a[1][4] = read() : 0;
            ( 1 <= n && 5 <= n ) ? a[1][5] = read() : 0;
            ( 1 <= n && 6 <= n ) ? a[1][6] = read() : 0;
            ( 1 <= n && 7 <= n ) ? a[1][7] = read() : 0;
            ( 1 <= n && 8 <= n ) ? a[1][8] = read() : 0;
            ( 1 <= n && 9 <= n ) ? a[1][9] = read() : 0;
            ( 1 <= n && 10 <= n ) ? a[1][10] = read() : 0;
            ( 2 <= n && 1 <= n ) ? a[2][1] = read() : 0;
            ( 2 <= n && 2 <= n ) ? a[2][2] = read() : 0;
            ( 2 <= n && 3 <= n ) ? a[2][3] = read() : 0;
            ( 2 <= n && 4 <= n ) ? a[2][4] = read() : 0;
            ( 2 <= n && 5 <= n ) ? a[2][5] = read() : 0;
            ( 2 <= n && 6 <= n ) ? a[2][6] = read() : 0;
            ( 2 <= n && 7 <= n ) ? a[2][7] = read() : 0;
            ( 2 <= n && 8 <= n ) ? a[2][8] = read() : 0;
            ( 2 <= n && 9 <= n ) ? a[2][9] = read() : 0;
            ( 2 <= n && 10 <= n ) ? a[2][10] = read() : 0;
            ( 3 <= n && 1 <= n ) ? a[3][1] = read() : 0;
            ( 3 <= n && 2 <= n ) ? a[3][2] = read() : 0;
            ( 3 <= n && 3 <= n ) ? a[3][3] = read() : 0;
            ( 3 <= n && 4 <= n ) ? a[3][4] = read() : 0;
            ( 3 <= n && 5 <= n ) ? a[3][5] = read() : 0;
            ( 3 <= n && 6 <= n ) ? a[3][6] = read() : 0;
            ( 3 <= n && 7 <= n ) ? a[3][7] = read() : 0;
            ( 3 <= n && 8 <= n ) ? a[3][8] = read() : 0;
            ( 3 <= n && 9 <= n ) ? a[3][9] = read() : 0;
            ( 3 <= n && 10 <= n ) ? a[3][10] = read() : 0;
            ( 4 <= n && 1 <= n ) ? a[4][1] = read() : 0;
            ( 4 <= n && 2 <= n ) ? a[4][2] = read() : 0;
            ( 4 <= n && 3 <= n ) ? a[4][3] = read() : 0;
            ( 4 <= n && 4 <= n ) ? a[4][4] = read() : 0;
            ( 4 <= n && 5 <= n ) ? a[4][5] = read() : 0;
            ( 4 <= n && 6 <= n ) ? a[4][6] = read() : 0;
            ( 4 <= n && 7 <= n ) ? a[4][7] = read() : 0;
            ( 4 <= n && 8 <= n ) ? a[4][8] = read() : 0;
            ( 4 <= n && 9 <= n ) ? a[4][9] = read() : 0;
            ( 4 <= n && 10 <= n ) ? a[4][10] = read() : 0;
            ( 5 <= n && 1 <= n ) ? a[5][1] = read() : 0;
            ( 5 <= n && 2 <= n ) ? a[5][2] = read() : 0;
            ( 5 <= n && 3 <= n ) ? a[5][3] = read() : 0;
            ( 5 <= n && 4 <= n ) ? a[5][4] = read() : 0;
            ( 5 <= n && 5 <= n ) ? a[5][5] = read() : 0;
            ( 5 <= n && 6 <= n ) ? a[5][6] = read() : 0;
            ( 5 <= n && 7 <= n ) ? a[5][7] = read() : 0;
            ( 5 <= n && 8 <= n ) ? a[5][8] = read() : 0;
            ( 5 <= n && 9 <= n ) ? a[5][9] = read() : 0;
            ( 5 <= n && 10 <= n ) ? a[5][10] = read() : 0;
            ( 6 <= n && 1 <= n ) ? a[6][1] = read() : 0;
            ( 6 <= n && 2 <= n ) ? a[6][2] = read() : 0;
            ( 6 <= n && 3 <= n ) ? a[6][3] = read() : 0;
            ( 6 <= n && 4 <= n ) ? a[6][4] = read() : 0;
            ( 6 <= n && 5 <= n ) ? a[6][5] = read() : 0;
            ( 6 <= n && 6 <= n ) ? a[6][6] = read() : 0;
            ( 6 <= n && 7 <= n ) ? a[6][7] = read() : 0;
            ( 6 <= n && 8 <= n ) ? a[6][8] = read() : 0;
            ( 6 <= n && 9 <= n ) ? a[6][9] = read() : 0;
            ( 6 <= n && 10 <= n ) ? a[6][10] = read() : 0;
            ( 7 <= n && 1 <= n ) ? a[7][1] = read() : 0;
            ( 7 <= n && 2 <= n ) ? a[7][2] = read() : 0;
            ( 7 <= n && 3 <= n ) ? a[7][3] = read() : 0;
            ( 7 <= n && 4 <= n ) ? a[7][4] = read() : 0;
            ( 7 <= n && 5 <= n ) ? a[7][5] = read() : 0;
            ( 7 <= n && 6 <= n ) ? a[7][6] = read() : 0;
            ( 7 <= n && 7 <= n ) ? a[7][7] = read() : 0;
            ( 7 <= n && 8 <= n ) ? a[7][8] = read() : 0;
            ( 7 <= n && 9 <= n ) ? a[7][9] = read() : 0;
            ( 7 <= n && 10 <= n ) ? a[7][10] = read() : 0;
            ( 8 <= n && 1 <= n ) ? a[8][1] = read() : 0;
            ( 8 <= n && 2 <= n ) ? a[8][2] = read() : 0;
            ( 8 <= n && 3 <= n ) ? a[8][3] = read() : 0;
            ( 8 <= n && 4 <= n ) ? a[8][4] = read() : 0;
            ( 8 <= n && 5 <= n ) ? a[8][5] = read() : 0;
            ( 8 <= n && 6 <= n ) ? a[8][6] = read() : 0;
            ( 8 <= n && 7 <= n ) ? a[8][7] = read() : 0;
            ( 8 <= n && 8 <= n ) ? a[8][8] = read() : 0;
            ( 8 <= n && 9 <= n ) ? a[8][9] = read() : 0;
            ( 8 <= n && 10 <= n ) ? a[8][10] = read() : 0;
            ( 9 <= n && 1 <= n ) ? a[9][1] = read() : 0;
            ( 9 <= n && 2 <= n ) ? a[9][2] = read() : 0;
            ( 9 <= n && 3 <= n ) ? a[9][3] = read() : 0;
            ( 9 <= n && 4 <= n ) ? a[9][4] = read() : 0;
            ( 9 <= n && 5 <= n ) ? a[9][5] = read() : 0;
            ( 9 <= n && 6 <= n ) ? a[9][6] = read() : 0;
            ( 9 <= n && 7 <= n ) ? a[9][7] = read() : 0;
            ( 9 <= n && 8 <= n ) ? a[9][8] = read() : 0;
            ( 9 <= n && 9 <= n ) ? a[9][9] = read() : 0;
            ( 9 <= n && 10 <= n ) ? a[9][10] = read() : 0;
            ( 10 <= n && 1 <= n ) ? a[10][1] = read() : 0;
            ( 10 <= n && 2 <= n ) ? a[10][2] = read() : 0;
            ( 10 <= n && 3 <= n ) ? a[10][3] = read() : 0;
            ( 10 <= n && 4 <= n ) ? a[10][4] = read() : 0;
            ( 10 <= n && 5 <= n ) ? a[10][5] = read() : 0;
            ( 10 <= n && 6 <= n ) ? a[10][6] = read() : 0;
            ( 10 <= n && 7 <= n ) ? a[10][7] = read() : 0;
            ( 10 <= n && 8 <= n ) ? a[10][8] = read() : 0;
            ( 10 <= n && 9 <= n ) ? a[10][9] = read() : 0;
            ( 10 <= n && 10 <= n ) ? a[10][10] = read() : 0;
            a[2][3] = min( a[2][3], a[2][1] + a[1][3] );
            a[2][4] = min( a[2][4], a[2][1] + a[1][4] );
            a[2][5] = min( a[2][5], a[2][1] + a[1][5] );
            a[2][6] = min( a[2][6], a[2][1] + a[1][6] );
            a[2][7] = min( a[2][7], a[2][1] + a[1][7] );
            a[2][8] = min( a[2][8], a[2][1] + a[1][8] );
            a[2][9] = min( a[2][9], a[2][1] + a[1][9] );
            a[2][10] = min( a[2][10], a[2][1] + a[1][10] );
            a[3][2] = min( a[3][2], a[3][1] + a[1][2] );
            a[3][4] = min( a[3][4], a[3][1] + a[1][4] );
            a[3][5] = min( a[3][5], a[3][1] + a[1][5] );
            a[3][6] = min( a[3][6], a[3][1] + a[1][6] );
            a[3][7] = min( a[3][7], a[3][1] + a[1][7] );
            a[3][8] = min( a[3][8], a[3][1] + a[1][8] );
            a[3][9] = min( a[3][9], a[3][1] + a[1][9] );
            a[3][10] = min( a[3][10], a[3][1] + a[1][10] );
            a[4][2] = min( a[4][2], a[4][1] + a[1][2] );
            a[4][3] = min( a[4][3], a[4][1] + a[1][3] );
            a[4][5] = min( a[4][5], a[4][1] + a[1][5] );
            a[4][6] = min( a[4][6], a[4][1] + a[1][6] );
            a[4][7] = min( a[4][7], a[4][1] + a[1][7] );
            a[4][8] = min( a[4][8], a[4][1] + a[1][8] );
            a[4][9] = min( a[4][9], a[4][1] + a[1][9] );
            a[4][10] = min( a[4][10], a[4][1] + a[1][10] );
            a[5][2] = min( a[5][2], a[5][1] + a[1][2] );
            a[5][3] = min( a[5][3], a[5][1] + a[1][3] );
            a[5][4] = min( a[5][4], a[5][1] + a[1][4] );
            a[5][6] = min( a[5][6], a[5][1] + a[1][6] );
            a[5][7] = min( a[5][7], a[5][1] + a[1][7] );
            a[5][8] = min( a[5][8], a[5][1] + a[1][8] );
            a[5][9] = min( a[5][9], a[5][1] + a[1][9] );
            a[5][10] = min( a[5][10], a[5][1] + a[1][10] );
            a[6][2] = min( a[6][2], a[6][1] + a[1][2] );
            a[6][3] = min( a[6][3], a[6][1] + a[1][3] );
            a[6][4] = min( a[6][4], a[6][1] + a[1][4] );
            a[6][5] = min( a[6][5], a[6][1] + a[1][5] );
            a[6][7] = min( a[6][7], a[6][1] + a[1][7] );
            a[6][8] = min( a[6][8], a[6][1] + a[1][8] );
            a[6][9] = min( a[6][9], a[6][1] + a[1][9] );
            a[6][10] = min( a[6][10], a[6][1] + a[1][10] );
            a[7][2] = min( a[7][2], a[7][1] + a[1][2] );
            a[7][3] = min( a[7][3], a[7][1] + a[1][3] );
            a[7][4] = min( a[7][4], a[7][1] + a[1][4] );
            a[7][5] = min( a[7][5], a[7][1] + a[1][5] );
            a[7][6] = min( a[7][6], a[7][1] + a[1][6] );
            a[7][8] = min( a[7][8], a[7][1] + a[1][8] );
            a[7][9] = min( a[7][9], a[7][1] + a[1][9] );
            a[7][10] = min( a[7][10], a[7][1] + a[1][10] );
            a[8][2] = min( a[8][2], a[8][1] + a[1][2] );
            a[8][3] = min( a[8][3], a[8][1] + a[1][3] );
            a[8][4] = min( a[8][4], a[8][1] + a[1][4] );
            a[8][5] = min( a[8][5], a[8][1] + a[1][5] );
            a[8][6] = min( a[8][6], a[8][1] + a[1][6] );
            a[8][7] = min( a[8][7], a[8][1] + a[1][7] );
            a[8][9] = min( a[8][9], a[8][1] + a[1][9] );
            a[8][10] = min( a[8][10], a[8][1] + a[1][10] );
            a[9][2] = min( a[9][2], a[9][1] + a[1][2] );
            a[9][3] = min( a[9][3], a[9][1] + a[1][3] );
            a[9][4] = min( a[9][4], a[9][1] + a[1][4] );
            a[9][5] = min( a[9][5], a[9][1] + a[1][5] );
            a[9][6] = min( a[9][6], a[9][1] + a[1][6] );
            a[9][7] = min( a[9][7], a[9][1] + a[1][7] );
            a[9][8] = min( a[9][8], a[9][1] + a[1][8] );
            a[9][10] = min( a[9][10], a[9][1] + a[1][10] );
            a[10][2] = min( a[10][2], a[10][1] + a[1][2] );
            a[10][3] = min( a[10][3], a[10][1] + a[1][3] );
            a[10][4] = min( a[10][4], a[10][1] + a[1][4] );
            a[10][5] = min( a[10][5], a[10][1] + a[1][5] );
            a[10][6] = min( a[10][6], a[10][1] + a[1][6] );
            a[10][7] = min( a[10][7], a[10][1] + a[1][7] );
            a[10][8] = min( a[10][8], a[10][1] + a[1][8] );
            a[10][9] = min( a[10][9], a[10][1] + a[1][9] );
            a[1][3] = min( a[1][3], a[1][2] + a[2][3] );
            a[1][4] = min( a[1][4], a[1][2] + a[2][4] );
            a[1][5] = min( a[1][5], a[1][2] + a[2][5] );
            a[1][6] = min( a[1][6], a[1][2] + a[2][6] );
            a[1][7] = min( a[1][7], a[1][2] + a[2][7] );
            a[1][8] = min( a[1][8], a[1][2] + a[2][8] );
            a[1][9] = min( a[1][9], a[1][2] + a[2][9] );
            a[1][10] = min( a[1][10], a[1][2] + a[2][10] );
            a[3][1] = min( a[3][1], a[3][2] + a[2][1] );
            a[3][4] = min( a[3][4], a[3][2] + a[2][4] );
            a[3][5] = min( a[3][5], a[3][2] + a[2][5] );
            a[3][6] = min( a[3][6], a[3][2] + a[2][6] );
            a[3][7] = min( a[3][7], a[3][2] + a[2][7] );
            a[3][8] = min( a[3][8], a[3][2] + a[2][8] );
            a[3][9] = min( a[3][9], a[3][2] + a[2][9] );
            a[3][10] = min( a[3][10], a[3][2] + a[2][10] );
            a[4][1] = min( a[4][1], a[4][2] + a[2][1] );
            a[4][3] = min( a[4][3], a[4][2] + a[2][3] );
            a[4][5] = min( a[4][5], a[4][2] + a[2][5] );
            a[4][6] = min( a[4][6], a[4][2] + a[2][6] );
            a[4][7] = min( a[4][7], a[4][2] + a[2][7] );
            a[4][8] = min( a[4][8], a[4][2] + a[2][8] );
            a[4][9] = min( a[4][9], a[4][2] + a[2][9] );
            a[4][10] = min( a[4][10], a[4][2] + a[2][10] );
            a[5][1] = min( a[5][1], a[5][2] + a[2][1] );
            a[5][3] = min( a[5][3], a[5][2] + a[2][3] );
            a[5][4] = min( a[5][4], a[5][2] + a[2][4] );
            a[5][6] = min( a[5][6], a[5][2] + a[2][6] );
            a[5][7] = min( a[5][7], a[5][2] + a[2][7] );
            a[5][8] = min( a[5][8], a[5][2] + a[2][8] );
            a[5][9] = min( a[5][9], a[5][2] + a[2][9] );
            a[5][10] = min( a[5][10], a[5][2] + a[2][10] );
            a[6][1] = min( a[6][1], a[6][2] + a[2][1] );
            a[6][3] = min( a[6][3], a[6][2] + a[2][3] );
            a[6][4] = min( a[6][4], a[6][2] + a[2][4] );
            a[6][5] = min( a[6][5], a[6][2] + a[2][5] );
            a[6][7] = min( a[6][7], a[6][2] + a[2][7] );
            a[6][8] = min( a[6][8], a[6][2] + a[2][8] );
            a[6][9] = min( a[6][9], a[6][2] + a[2][9] );
            a[6][10] = min( a[6][10], a[6][2] + a[2][10] );
            a[7][1] = min( a[7][1], a[7][2] + a[2][1] );
            a[7][3] = min( a[7][3], a[7][2] + a[2][3] );
            a[7][4] = min( a[7][4], a[7][2] + a[2][4] );
            a[7][5] = min( a[7][5], a[7][2] + a[2][5] );
            a[7][6] = min( a[7][6], a[7][2] + a[2][6] );
            a[7][8] = min( a[7][8], a[7][2] + a[2][8] );
            a[7][9] = min( a[7][9], a[7][2] + a[2][9] );
            a[7][10] = min( a[7][10], a[7][2] + a[2][10] );
            a[8][1] = min( a[8][1], a[8][2] + a[2][1] );
            a[8][3] = min( a[8][3], a[8][2] + a[2][3] );
            a[8][4] = min( a[8][4], a[8][2] + a[2][4] );
            a[8][5] = min( a[8][5], a[8][2] + a[2][5] );
            a[8][6] = min( a[8][6], a[8][2] + a[2][6] );
            a[8][7] = min( a[8][7], a[8][2] + a[2][7] );
            a[8][9] = min( a[8][9], a[8][2] + a[2][9] );
            a[8][10] = min( a[8][10], a[8][2] + a[2][10] );
            a[9][1] = min( a[9][1], a[9][2] + a[2][1] );
            a[9][3] = min( a[9][3], a[9][2] + a[2][3] );
            a[9][4] = min( a[9][4], a[9][2] + a[2][4] );
            a[9][5] = min( a[9][5], a[9][2] + a[2][5] );
            a[9][6] = min( a[9][6], a[9][2] + a[2][6] );
            a[9][7] = min( a[9][7], a[9][2] + a[2][7] );
            a[9][8] = min( a[9][8], a[9][2] + a[2][8] );
            a[9][10] = min( a[9][10], a[9][2] + a[2][10] );
            a[10][1] = min( a[10][1], a[10][2] + a[2][1] );
            a[10][3] = min( a[10][3], a[10][2] + a[2][3] );
            a[10][4] = min( a[10][4], a[10][2] + a[2][4] );
            a[10][5] = min( a[10][5], a[10][2] + a[2][5] );
            a[10][6] = min( a[10][6], a[10][2] + a[2][6] );
            a[10][7] = min( a[10][7], a[10][2] + a[2][7] );
            a[10][8] = min( a[10][8], a[10][2] + a[2][8] );
            a[10][9] = min( a[10][9], a[10][2] + a[2][9] );
            a[1][2] = min( a[1][2], a[1][3] + a[3][2] );
            a[1][4] = min( a[1][4], a[1][3] + a[3][4] );
            a[1][5] = min( a[1][5], a[1][3] + a[3][5] );
            a[1][6] = min( a[1][6], a[1][3] + a[3][6] );
            a[1][7] = min( a[1][7], a[1][3] + a[3][7] );
            a[1][8] = min( a[1][8], a[1][3] + a[3][8] );
            a[1][9] = min( a[1][9], a[1][3] + a[3][9] );
            a[1][10] = min( a[1][10], a[1][3] + a[3][10] );
            a[2][1] = min( a[2][1], a[2][3] + a[3][1] );
            a[2][4] = min( a[2][4], a[2][3] + a[3][4] );
            a[2][5] = min( a[2][5], a[2][3] + a[3][5] );
            a[2][6] = min( a[2][6], a[2][3] + a[3][6] );
            a[2][7] = min( a[2][7], a[2][3] + a[3][7] );
            a[2][8] = min( a[2][8], a[2][3] + a[3][8] );
            a[2][9] = min( a[2][9], a[2][3] + a[3][9] );
            a[2][10] = min( a[2][10], a[2][3] + a[3][10] );
            a[4][1] = min( a[4][1], a[4][3] + a[3][1] );
            a[4][2] = min( a[4][2], a[4][3] + a[3][2] );
            a[4][5] = min( a[4][5], a[4][3] + a[3][5] );
            a[4][6] = min( a[4][6], a[4][3] + a[3][6] );
            a[4][7] = min( a[4][7], a[4][3] + a[3][7] );
            a[4][8] = min( a[4][8], a[4][3] + a[3][8] );
            a[4][9] = min( a[4][9], a[4][3] + a[3][9] );
            a[4][10] = min( a[4][10], a[4][3] + a[3][10] );
            a[5][1] = min( a[5][1], a[5][3] + a[3][1] );
            a[5][2] = min( a[5][2], a[5][3] + a[3][2] );
            a[5][4] = min( a[5][4], a[5][3] + a[3][4] );
            a[5][6] = min( a[5][6], a[5][3] + a[3][6] );
            a[5][7] = min( a[5][7], a[5][3] + a[3][7] );
            a[5][8] = min( a[5][8], a[5][3] + a[3][8] );
            a[5][9] = min( a[5][9], a[5][3] + a[3][9] );
            a[5][10] = min( a[5][10], a[5][3] + a[3][10] );
            a[6][1] = min( a[6][1], a[6][3] + a[3][1] );
            a[6][2] = min( a[6][2], a[6][3] + a[3][2] );
            a[6][4] = min( a[6][4], a[6][3] + a[3][4] );
            a[6][5] = min( a[6][5], a[6][3] + a[3][5] );
            a[6][7] = min( a[6][7], a[6][3] + a[3][7] );
            a[6][8] = min( a[6][8], a[6][3] + a[3][8] );
            a[6][9] = min( a[6][9], a[6][3] + a[3][9] );
            a[6][10] = min( a[6][10], a[6][3] + a[3][10] );
            a[7][1] = min( a[7][1], a[7][3] + a[3][1] );
            a[7][2] = min( a[7][2], a[7][3] + a[3][2] );
            a[7][4] = min( a[7][4], a[7][3] + a[3][4] );
            a[7][5] = min( a[7][5], a[7][3] + a[3][5] );
            a[7][6] = min( a[7][6], a[7][3] + a[3][6] );
            a[7][8] = min( a[7][8], a[7][3] + a[3][8] );
            a[7][9] = min( a[7][9], a[7][3] + a[3][9] );
            a[7][10] = min( a[7][10], a[7][3] + a[3][10] );
            a[8][1] = min( a[8][1], a[8][3] + a[3][1] );
            a[8][2] = min( a[8][2], a[8][3] + a[3][2] );
            a[8][4] = min( a[8][4], a[8][3] + a[3][4] );
            a[8][5] = min( a[8][5], a[8][3] + a[3][5] );
            a[8][6] = min( a[8][6], a[8][3] + a[3][6] );
            a[8][7] = min( a[8][7], a[8][3] + a[3][7] );
            a[8][9] = min( a[8][9], a[8][3] + a[3][9] );
            a[8][10] = min( a[8][10], a[8][3] + a[3][10] );
            a[9][1] = min( a[9][1], a[9][3] + a[3][1] );
            a[9][2] = min( a[9][2], a[9][3] + a[3][2] );
            a[9][4] = min( a[9][4], a[9][3] + a[3][4] );
            a[9][5] = min( a[9][5], a[9][3] + a[3][5] );
            a[9][6] = min( a[9][6], a[9][3] + a[3][6] );
            a[9][7] = min( a[9][7], a[9][3] + a[3][7] );
            a[9][8] = min( a[9][8], a[9][3] + a[3][8] );
            a[9][10] = min( a[9][10], a[9][3] + a[3][10] );
            a[10][1] = min( a[10][1], a[10][3] + a[3][1] );
            a[10][2] = min( a[10][2], a[10][3] + a[3][2] );
            a[10][4] = min( a[10][4], a[10][3] + a[3][4] );
            a[10][5] = min( a[10][5], a[10][3] + a[3][5] );
            a[10][6] = min( a[10][6], a[10][3] + a[3][6] );
            a[10][7] = min( a[10][7], a[10][3] + a[3][7] );
            a[10][8] = min( a[10][8], a[10][3] + a[3][8] );
            a[10][9] = min( a[10][9], a[10][3] + a[3][9] );
            a[1][2] = min( a[1][2], a[1][4] + a[4][2] );
            a[1][3] = min( a[1][3], a[1][4] + a[4][3] );
            a[1][5] = min( a[1][5], a[1][4] + a[4][5] );
            a[1][6] = min( a[1][6], a[1][4] + a[4][6] );
            a[1][7] = min( a[1][7], a[1][4] + a[4][7] );
            a[1][8] = min( a[1][8], a[1][4] + a[4][8] );
            a[1][9] = min( a[1][9], a[1][4] + a[4][9] );
            a[1][10] = min( a[1][10], a[1][4] + a[4][10] );
            a[2][1] = min( a[2][1], a[2][4] + a[4][1] );
            a[2][3] = min( a[2][3], a[2][4] + a[4][3] );
            a[2][5] = min( a[2][5], a[2][4] + a[4][5] );
            a[2][6] = min( a[2][6], a[2][4] + a[4][6] );
            a[2][7] = min( a[2][7], a[2][4] + a[4][7] );
            a[2][8] = min( a[2][8], a[2][4] + a[4][8] );
            a[2][9] = min( a[2][9], a[2][4] + a[4][9] );
            a[2][10] = min( a[2][10], a[2][4] + a[4][10] );
            a[3][1] = min( a[3][1], a[3][4] + a[4][1] );
            a[3][2] = min( a[3][2], a[3][4] + a[4][2] );
            a[3][5] = min( a[3][5], a[3][4] + a[4][5] );
            a[3][6] = min( a[3][6], a[3][4] + a[4][6] );
            a[3][7] = min( a[3][7], a[3][4] + a[4][7] );
            a[3][8] = min( a[3][8], a[3][4] + a[4][8] );
            a[3][9] = min( a[3][9], a[3][4] + a[4][9] );
            a[3][10] = min( a[3][10], a[3][4] + a[4][10] );
            a[5][1] = min( a[5][1], a[5][4] + a[4][1] );
            a[5][2] = min( a[5][2], a[5][4] + a[4][2] );
            a[5][3] = min( a[5][3], a[5][4] + a[4][3] );
            a[5][6] = min( a[5][6], a[5][4] + a[4][6] );
            a[5][7] = min( a[5][7], a[5][4] + a[4][7] );
            a[5][8] = min( a[5][8], a[5][4] + a[4][8] );
            a[5][9] = min( a[5][9], a[5][4] + a[4][9] );
            a[5][10] = min( a[5][10], a[5][4] + a[4][10] );
            a[6][1] = min( a[6][1], a[6][4] + a[4][1] );
            a[6][2] = min( a[6][2], a[6][4] + a[4][2] );
            a[6][3] = min( a[6][3], a[6][4] + a[4][3] );
            a[6][5] = min( a[6][5], a[6][4] + a[4][5] );
            a[6][7] = min( a[6][7], a[6][4] + a[4][7] );
            a[6][8] = min( a[6][8], a[6][4] + a[4][8] );
            a[6][9] = min( a[6][9], a[6][4] + a[4][9] );
            a[6][10] = min( a[6][10], a[6][4] + a[4][10] );
            a[7][1] = min( a[7][1], a[7][4] + a[4][1] );
            a[7][2] = min( a[7][2], a[7][4] + a[4][2] );
            a[7][3] = min( a[7][3], a[7][4] + a[4][3] );
            a[7][5] = min( a[7][5], a[7][4] + a[4][5] );
            a[7][6] = min( a[7][6], a[7][4] + a[4][6] );
            a[7][8] = min( a[7][8], a[7][4] + a[4][8] );
            a[7][9] = min( a[7][9], a[7][4] + a[4][9] );
            a[7][10] = min( a[7][10], a[7][4] + a[4][10] );
            a[8][1] = min( a[8][1], a[8][4] + a[4][1] );
            a[8][2] = min( a[8][2], a[8][4] + a[4][2] );
            a[8][3] = min( a[8][3], a[8][4] + a[4][3] );
            a[8][5] = min( a[8][5], a[8][4] + a[4][5] );
            a[8][6] = min( a[8][6], a[8][4] + a[4][6] );
            a[8][7] = min( a[8][7], a[8][4] + a[4][7] );
            a[8][9] = min( a[8][9], a[8][4] + a[4][9] );
            a[8][10] = min( a[8][10], a[8][4] + a[4][10] );
            a[9][1] = min( a[9][1], a[9][4] + a[4][1] );
            a[9][2] = min( a[9][2], a[9][4] + a[4][2] );
            a[9][3] = min( a[9][3], a[9][4] + a[4][3] );
            a[9][5] = min( a[9][5], a[9][4] + a[4][5] );
            a[9][6] = min( a[9][6], a[9][4] + a[4][6] );
            a[9][7] = min( a[9][7], a[9][4] + a[4][7] );
            a[9][8] = min( a[9][8], a[9][4] + a[4][8] );
            a[9][10] = min( a[9][10], a[9][4] + a[4][10] );
            a[10][1] = min( a[10][1], a[10][4] + a[4][1] );
            a[10][2] = min( a[10][2], a[10][4] + a[4][2] );
            a[10][3] = min( a[10][3], a[10][4] + a[4][3] );
            a[10][5] = min( a[10][5], a[10][4] + a[4][5] );
            a[10][6] = min( a[10][6], a[10][4] + a[4][6] );
            a[10][7] = min( a[10][7], a[10][4] + a[4][7] );
            a[10][8] = min( a[10][8], a[10][4] + a[4][8] );
            a[10][9] = min( a[10][9], a[10][4] + a[4][9] );
            a[1][2] = min( a[1][2], a[1][5] + a[5][2] );
            a[1][3] = min( a[1][3], a[1][5] + a[5][3] );
            a[1][4] = min( a[1][4], a[1][5] + a[5][4] );
            a[1][6] = min( a[1][6], a[1][5] + a[5][6] );
            a[1][7] = min( a[1][7], a[1][5] + a[5][7] );
            a[1][8] = min( a[1][8], a[1][5] + a[5][8] );
            a[1][9] = min( a[1][9], a[1][5] + a[5][9] );
            a[1][10] = min( a[1][10], a[1][5] + a[5][10] );
            a[2][1] = min( a[2][1], a[2][5] + a[5][1] );
            a[2][3] = min( a[2][3], a[2][5] + a[5][3] );
            a[2][4] = min( a[2][4], a[2][5] + a[5][4] );
            a[2][6] = min( a[2][6], a[2][5] + a[5][6] );
            a[2][7] = min( a[2][7], a[2][5] + a[5][7] );
            a[2][8] = min( a[2][8], a[2][5] + a[5][8] );
            a[2][9] = min( a[2][9], a[2][5] + a[5][9] );
            a[2][10] = min( a[2][10], a[2][5] + a[5][10] );
            a[3][1] = min( a[3][1], a[3][5] + a[5][1] );
            a[3][2] = min( a[3][2], a[3][5] + a[5][2] );
            a[3][4] = min( a[3][4], a[3][5] + a[5][4] );
            a[3][6] = min( a[3][6], a[3][5] + a[5][6] );
            a[3][7] = min( a[3][7], a[3][5] + a[5][7] );
            a[3][8] = min( a[3][8], a[3][5] + a[5][8] );
            a[3][9] = min( a[3][9], a[3][5] + a[5][9] );
            a[3][10] = min( a[3][10], a[3][5] + a[5][10] );
            a[4][1] = min( a[4][1], a[4][5] + a[5][1] );
            a[4][2] = min( a[4][2], a[4][5] + a[5][2] );
            a[4][3] = min( a[4][3], a[4][5] + a[5][3] );
            a[4][6] = min( a[4][6], a[4][5] + a[5][6] );
            a[4][7] = min( a[4][7], a[4][5] + a[5][7] );
            a[4][8] = min( a[4][8], a[4][5] + a[5][8] );
            a[4][9] = min( a[4][9], a[4][5] + a[5][9] );
            a[4][10] = min( a[4][10], a[4][5] + a[5][10] );
            a[6][1] = min( a[6][1], a[6][5] + a[5][1] );
            a[6][2] = min( a[6][2], a[6][5] + a[5][2] );
            a[6][3] = min( a[6][3], a[6][5] + a[5][3] );
            a[6][4] = min( a[6][4], a[6][5] + a[5][4] );
            a[6][7] = min( a[6][7], a[6][5] + a[5][7] );
            a[6][8] = min( a[6][8], a[6][5] + a[5][8] );
            a[6][9] = min( a[6][9], a[6][5] + a[5][9] );
            a[6][10] = min( a[6][10], a[6][5] + a[5][10] );
            a[7][1] = min( a[7][1], a[7][5] + a[5][1] );
            a[7][2] = min( a[7][2], a[7][5] + a[5][2] );
            a[7][3] = min( a[7][3], a[7][5] + a[5][3] );
            a[7][4] = min( a[7][4], a[7][5] + a[5][4] );
            a[7][6] = min( a[7][6], a[7][5] + a[5][6] );
            a[7][8] = min( a[7][8], a[7][5] + a[5][8] );
            a[7][9] = min( a[7][9], a[7][5] + a[5][9] );
            a[7][10] = min( a[7][10], a[7][5] + a[5][10] );
            a[8][1] = min( a[8][1], a[8][5] + a[5][1] );
            a[8][2] = min( a[8][2], a[8][5] + a[5][2] );
            a[8][3] = min( a[8][3], a[8][5] + a[5][3] );
            a[8][4] = min( a[8][4], a[8][5] + a[5][4] );
            a[8][6] = min( a[8][6], a[8][5] + a[5][6] );
            a[8][7] = min( a[8][7], a[8][5] + a[5][7] );
            a[8][9] = min( a[8][9], a[8][5] + a[5][9] );
            a[8][10] = min( a[8][10], a[8][5] + a[5][10] );
            a[9][1] = min( a[9][1], a[9][5] + a[5][1] );
            a[9][2] = min( a[9][2], a[9][5] + a[5][2] );
            a[9][3] = min( a[9][3], a[9][5] + a[5][3] );
            a[9][4] = min( a[9][4], a[9][5] + a[5][4] );
            a[9][6] = min( a[9][6], a[9][5] + a[5][6] );
            a[9][7] = min( a[9][7], a[9][5] + a[5][7] );
            a[9][8] = min( a[9][8], a[9][5] + a[5][8] );
            a[9][10] = min( a[9][10], a[9][5] + a[5][10] );
            a[10][1] = min( a[10][1], a[10][5] + a[5][1] );
            a[10][2] = min( a[10][2], a[10][5] + a[5][2] );
            a[10][3] = min( a[10][3], a[10][5] + a[5][3] );
            a[10][4] = min( a[10][4], a[10][5] + a[5][4] );
            a[10][6] = min( a[10][6], a[10][5] + a[5][6] );
            a[10][7] = min( a[10][7], a[10][5] + a[5][7] );
            a[10][8] = min( a[10][8], a[10][5] + a[5][8] );
            a[10][9] = min( a[10][9], a[10][5] + a[5][9] );
            a[1][2] = min( a[1][2], a[1][6] + a[6][2] );
            a[1][3] = min( a[1][3], a[1][6] + a[6][3] );
            a[1][4] = min( a[1][4], a[1][6] + a[6][4] );
            a[1][5] = min( a[1][5], a[1][6] + a[6][5] );
            a[1][7] = min( a[1][7], a[1][6] + a[6][7] );
            a[1][8] = min( a[1][8], a[1][6] + a[6][8] );
            a[1][9] = min( a[1][9], a[1][6] + a[6][9] );
            a[1][10] = min( a[1][10], a[1][6] + a[6][10] );
            a[2][1] = min( a[2][1], a[2][6] + a[6][1] );
            a[2][3] = min( a[2][3], a[2][6] + a[6][3] );
            a[2][4] = min( a[2][4], a[2][6] + a[6][4] );
            a[2][5] = min( a[2][5], a[2][6] + a[6][5] );
            a[2][7] = min( a[2][7], a[2][6] + a[6][7] );
            a[2][8] = min( a[2][8], a[2][6] + a[6][8] );
            a[2][9] = min( a[2][9], a[2][6] + a[6][9] );
            a[2][10] = min( a[2][10], a[2][6] + a[6][10] );
            a[3][1] = min( a[3][1], a[3][6] + a[6][1] );
            a[3][2] = min( a[3][2], a[3][6] + a[6][2] );
            a[3][4] = min( a[3][4], a[3][6] + a[6][4] );
            a[3][5] = min( a[3][5], a[3][6] + a[6][5] );
            a[3][7] = min( a[3][7], a[3][6] + a[6][7] );
            a[3][8] = min( a[3][8], a[3][6] + a[6][8] );
            a[3][9] = min( a[3][9], a[3][6] + a[6][9] );
            a[3][10] = min( a[3][10], a[3][6] + a[6][10] );
            a[4][1] = min( a[4][1], a[4][6] + a[6][1] );
            a[4][2] = min( a[4][2], a[4][6] + a[6][2] );
            a[4][3] = min( a[4][3], a[4][6] + a[6][3] );
            a[4][5] = min( a[4][5], a[4][6] + a[6][5] );
            a[4][7] = min( a[4][7], a[4][6] + a[6][7] );
            a[4][8] = min( a[4][8], a[4][6] + a[6][8] );
            a[4][9] = min( a[4][9], a[4][6] + a[6][9] );
            a[4][10] = min( a[4][10], a[4][6] + a[6][10] );
            a[5][1] = min( a[5][1], a[5][6] + a[6][1] );
            a[5][2] = min( a[5][2], a[5][6] + a[6][2] );
            a[5][3] = min( a[5][3], a[5][6] + a[6][3] );
            a[5][4] = min( a[5][4], a[5][6] + a[6][4] );
            a[5][7] = min( a[5][7], a[5][6] + a[6][7] );
            a[5][8] = min( a[5][8], a[5][6] + a[6][8] );
            a[5][9] = min( a[5][9], a[5][6] + a[6][9] );
            a[5][10] = min( a[5][10], a[5][6] + a[6][10] );
            a[7][1] = min( a[7][1], a[7][6] + a[6][1] );
            a[7][2] = min( a[7][2], a[7][6] + a[6][2] );
            a[7][3] = min( a[7][3], a[7][6] + a[6][3] );
            a[7][4] = min( a[7][4], a[7][6] + a[6][4] );
            a[7][5] = min( a[7][5], a[7][6] + a[6][5] );
            a[7][8] = min( a[7][8], a[7][6] + a[6][8] );
            a[7][9] = min( a[7][9], a[7][6] + a[6][9] );
            a[7][10] = min( a[7][10], a[7][6] + a[6][10] );
            a[8][1] = min( a[8][1], a[8][6] + a[6][1] );
            a[8][2] = min( a[8][2], a[8][6] + a[6][2] );
            a[8][3] = min( a[8][3], a[8][6] + a[6][3] );
            a[8][4] = min( a[8][4], a[8][6] + a[6][4] );
            a[8][5] = min( a[8][5], a[8][6] + a[6][5] );
            a[8][7] = min( a[8][7], a[8][6] + a[6][7] );
            a[8][9] = min( a[8][9], a[8][6] + a[6][9] );
            a[8][10] = min( a[8][10], a[8][6] + a[6][10] );
            a[9][1] = min( a[9][1], a[9][6] + a[6][1] );
            a[9][2] = min( a[9][2], a[9][6] + a[6][2] );
            a[9][3] = min( a[9][3], a[9][6] + a[6][3] );
            a[9][4] = min( a[9][4], a[9][6] + a[6][4] );
            a[9][5] = min( a[9][5], a[9][6] + a[6][5] );
            a[9][7] = min( a[9][7], a[9][6] + a[6][7] );
            a[9][8] = min( a[9][8], a[9][6] + a[6][8] );
            a[9][10] = min( a[9][10], a[9][6] + a[6][10] );
            a[10][1] = min( a[10][1], a[10][6] + a[6][1] );
            a[10][2] = min( a[10][2], a[10][6] + a[6][2] );
            a[10][3] = min( a[10][3], a[10][6] + a[6][3] );
            a[10][4] = min( a[10][4], a[10][6] + a[6][4] );
            a[10][5] = min( a[10][5], a[10][6] + a[6][5] );
            a[10][7] = min( a[10][7], a[10][6] + a[6][7] );
            a[10][8] = min( a[10][8], a[10][6] + a[6][8] );
            a[10][9] = min( a[10][9], a[10][6] + a[6][9] );
            a[1][2] = min( a[1][2], a[1][7] + a[7][2] );
            a[1][3] = min( a[1][3], a[1][7] + a[7][3] );
            a[1][4] = min( a[1][4], a[1][7] + a[7][4] );
            a[1][5] = min( a[1][5], a[1][7] + a[7][5] );
            a[1][6] = min( a[1][6], a[1][7] + a[7][6] );
            a[1][8] = min( a[1][8], a[1][7] + a[7][8] );
            a[1][9] = min( a[1][9], a[1][7] + a[7][9] );
            a[1][10] = min( a[1][10], a[1][7] + a[7][10] );
            a[2][1] = min( a[2][1], a[2][7] + a[7][1] );
            a[2][3] = min( a[2][3], a[2][7] + a[7][3] );
            a[2][4] = min( a[2][4], a[2][7] + a[7][4] );
            a[2][5] = min( a[2][5], a[2][7] + a[7][5] );
            a[2][6] = min( a[2][6], a[2][7] + a[7][6] );
            a[2][8] = min( a[2][8], a[2][7] + a[7][8] );
            a[2][9] = min( a[2][9], a[2][7] + a[7][9] );
            a[2][10] = min( a[2][10], a[2][7] + a[7][10] );
            a[3][1] = min( a[3][1], a[3][7] + a[7][1] );
            a[3][2] = min( a[3][2], a[3][7] + a[7][2] );
            a[3][4] = min( a[3][4], a[3][7] + a[7][4] );
            a[3][5] = min( a[3][5], a[3][7] + a[7][5] );
            a[3][6] = min( a[3][6], a[3][7] + a[7][6] );
            a[3][8] = min( a[3][8], a[3][7] + a[7][8] );
            a[3][9] = min( a[3][9], a[3][7] + a[7][9] );
            a[3][10] = min( a[3][10], a[3][7] + a[7][10] );
            a[4][1] = min( a[4][1], a[4][7] + a[7][1] );
            a[4][2] = min( a[4][2], a[4][7] + a[7][2] );
            a[4][3] = min( a[4][3], a[4][7] + a[7][3] );
            a[4][5] = min( a[4][5], a[4][7] + a[7][5] );
            a[4][6] = min( a[4][6], a[4][7] + a[7][6] );
            a[4][8] = min( a[4][8], a[4][7] + a[7][8] );
            a[4][9] = min( a[4][9], a[4][7] + a[7][9] );
            a[4][10] = min( a[4][10], a[4][7] + a[7][10] );
            a[5][1] = min( a[5][1], a[5][7] + a[7][1] );
            a[5][2] = min( a[5][2], a[5][7] + a[7][2] );
            a[5][3] = min( a[5][3], a[5][7] + a[7][3] );
            a[5][4] = min( a[5][4], a[5][7] + a[7][4] );
            a[5][6] = min( a[5][6], a[5][7] + a[7][6] );
            a[5][8] = min( a[5][8], a[5][7] + a[7][8] );
            a[5][9] = min( a[5][9], a[5][7] + a[7][9] );
            a[5][10] = min( a[5][10], a[5][7] + a[7][10] );
            a[6][1] = min( a[6][1], a[6][7] + a[7][1] );
            a[6][2] = min( a[6][2], a[6][7] + a[7][2] );
            a[6][3] = min( a[6][3], a[6][7] + a[7][3] );
            a[6][4] = min( a[6][4], a[6][7] + a[7][4] );
            a[6][5] = min( a[6][5], a[6][7] + a[7][5] );
            a[6][8] = min( a[6][8], a[6][7] + a[7][8] );
            a[6][9] = min( a[6][9], a[6][7] + a[7][9] );
            a[6][10] = min( a[6][10], a[6][7] + a[7][10] );
            a[8][1] = min( a[8][1], a[8][7] + a[7][1] );
            a[8][2] = min( a[8][2], a[8][7] + a[7][2] );
            a[8][3] = min( a[8][3], a[8][7] + a[7][3] );
            a[8][4] = min( a[8][4], a[8][7] + a[7][4] );
            a[8][5] = min( a[8][5], a[8][7] + a[7][5] );
            a[8][6] = min( a[8][6], a[8][7] + a[7][6] );
            a[8][9] = min( a[8][9], a[8][7] + a[7][9] );
            a[8][10] = min( a[8][10], a[8][7] + a[7][10] );
            a[9][1] = min( a[9][1], a[9][7] + a[7][1] );
            a[9][2] = min( a[9][2], a[9][7] + a[7][2] );
            a[9][3] = min( a[9][3], a[9][7] + a[7][3] );
            a[9][4] = min( a[9][4], a[9][7] + a[7][4] );
            a[9][5] = min( a[9][5], a[9][7] + a[7][5] );
            a[9][6] = min( a[9][6], a[9][7] + a[7][6] );
            a[9][8] = min( a[9][8], a[9][7] + a[7][8] );
            a[9][10] = min( a[9][10], a[9][7] + a[7][10] );
            a[10][1] = min( a[10][1], a[10][7] + a[7][1] );
            a[10][2] = min( a[10][2], a[10][7] + a[7][2] );
            a[10][3] = min( a[10][3], a[10][7] + a[7][3] );
            a[10][4] = min( a[10][4], a[10][7] + a[7][4] );
            a[10][5] = min( a[10][5], a[10][7] + a[7][5] );
            a[10][6] = min( a[10][6], a[10][7] + a[7][6] );
            a[10][8] = min( a[10][8], a[10][7] + a[7][8] );
            a[10][9] = min( a[10][9], a[10][7] + a[7][9] );
            a[1][2] = min( a[1][2], a[1][8] + a[8][2] );
            a[1][3] = min( a[1][3], a[1][8] + a[8][3] );
            a[1][4] = min( a[1][4], a[1][8] + a[8][4] );
            a[1][5] = min( a[1][5], a[1][8] + a[8][5] );
            a[1][6] = min( a[1][6], a[1][8] + a[8][6] );
            a[1][7] = min( a[1][7], a[1][8] + a[8][7] );
            a[1][9] = min( a[1][9], a[1][8] + a[8][9] );
            a[1][10] = min( a[1][10], a[1][8] + a[8][10] );
            a[2][1] = min( a[2][1], a[2][8] + a[8][1] );
            a[2][3] = min( a[2][3], a[2][8] + a[8][3] );
            a[2][4] = min( a[2][4], a[2][8] + a[8][4] );
            a[2][5] = min( a[2][5], a[2][8] + a[8][5] );
            a[2][6] = min( a[2][6], a[2][8] + a[8][6] );
            a[2][7] = min( a[2][7], a[2][8] + a[8][7] );
            a[2][9] = min( a[2][9], a[2][8] + a[8][9] );
            a[2][10] = min( a[2][10], a[2][8] + a[8][10] );
            a[3][1] = min( a[3][1], a[3][8] + a[8][1] );
            a[3][2] = min( a[3][2], a[3][8] + a[8][2] );
            a[3][4] = min( a[3][4], a[3][8] + a[8][4] );
            a[3][5] = min( a[3][5], a[3][8] + a[8][5] );
            a[3][6] = min( a[3][6], a[3][8] + a[8][6] );
            a[3][7] = min( a[3][7], a[3][8] + a[8][7] );
            a[3][9] = min( a[3][9], a[3][8] + a[8][9] );
            a[3][10] = min( a[3][10], a[3][8] + a[8][10] );
            a[4][1] = min( a[4][1], a[4][8] + a[8][1] );
            a[4][2] = min( a[4][2], a[4][8] + a[8][2] );
            a[4][3] = min( a[4][3], a[4][8] + a[8][3] );
            a[4][5] = min( a[4][5], a[4][8] + a[8][5] );
            a[4][6] = min( a[4][6], a[4][8] + a[8][6] );
            a[4][7] = min( a[4][7], a[4][8] + a[8][7] );
            a[4][9] = min( a[4][9], a[4][8] + a[8][9] );
            a[4][10] = min( a[4][10], a[4][8] + a[8][10] );
            a[5][1] = min( a[5][1], a[5][8] + a[8][1] );
            a[5][2] = min( a[5][2], a[5][8] + a[8][2] );
            a[5][3] = min( a[5][3], a[5][8] + a[8][3] );
            a[5][4] = min( a[5][4], a[5][8] + a[8][4] );
            a[5][6] = min( a[5][6], a[5][8] + a[8][6] );
            a[5][7] = min( a[5][7], a[5][8] + a[8][7] );
            a[5][9] = min( a[5][9], a[5][8] + a[8][9] );
            a[5][10] = min( a[5][10], a[5][8] + a[8][10] );
            a[6][1] = min( a[6][1], a[6][8] + a[8][1] );
            a[6][2] = min( a[6][2], a[6][8] + a[8][2] );
            a[6][3] = min( a[6][3], a[6][8] + a[8][3] );
            a[6][4] = min( a[6][4], a[6][8] + a[8][4] );
            a[6][5] = min( a[6][5], a[6][8] + a[8][5] );
            a[6][7] = min( a[6][7], a[6][8] + a[8][7] );
            a[6][9] = min( a[6][9], a[6][8] + a[8][9] );
            a[6][10] = min( a[6][10], a[6][8] + a[8][10] );
            a[7][1] = min( a[7][1], a[7][8] + a[8][1] );
            a[7][2] = min( a[7][2], a[7][8] + a[8][2] );
            a[7][3] = min( a[7][3], a[7][8] + a[8][3] );
            a[7][4] = min( a[7][4], a[7][8] + a[8][4] );
            a[7][5] = min( a[7][5], a[7][8] + a[8][5] );
            a[7][6] = min( a[7][6], a[7][8] + a[8][6] );
            a[7][9] = min( a[7][9], a[7][8] + a[8][9] );
            a[7][10] = min( a[7][10], a[7][8] + a[8][10] );
            a[9][1] = min( a[9][1], a[9][8] + a[8][1] );
            a[9][2] = min( a[9][2], a[9][8] + a[8][2] );
            a[9][3] = min( a[9][3], a[9][8] + a[8][3] );
            a[9][4] = min( a[9][4], a[9][8] + a[8][4] );
            a[9][5] = min( a[9][5], a[9][8] + a[8][5] );
            a[9][6] = min( a[9][6], a[9][8] + a[8][6] );
            a[9][7] = min( a[9][7], a[9][8] + a[8][7] );
            a[9][10] = min( a[9][10], a[9][8] + a[8][10] );
            a[10][1] = min( a[10][1], a[10][8] + a[8][1] );
            a[10][2] = min( a[10][2], a[10][8] + a[8][2] );
            a[10][3] = min( a[10][3], a[10][8] + a[8][3] );
            a[10][4] = min( a[10][4], a[10][8] + a[8][4] );
            a[10][5] = min( a[10][5], a[10][8] + a[8][5] );
            a[10][6] = min( a[10][6], a[10][8] + a[8][6] );
            a[10][7] = min( a[10][7], a[10][8] + a[8][7] );
            a[10][9] = min( a[10][9], a[10][8] + a[8][9] );
            a[1][2] = min( a[1][2], a[1][9] + a[9][2] );
            a[1][3] = min( a[1][3], a[1][9] + a[9][3] );
            a[1][4] = min( a[1][4], a[1][9] + a[9][4] );
            a[1][5] = min( a[1][5], a[1][9] + a[9][5] );
            a[1][6] = min( a[1][6], a[1][9] + a[9][6] );
            a[1][7] = min( a[1][7], a[1][9] + a[9][7] );
            a[1][8] = min( a[1][8], a[1][9] + a[9][8] );
            a[1][10] = min( a[1][10], a[1][9] + a[9][10] );
            a[2][1] = min( a[2][1], a[2][9] + a[9][1] );
            a[2][3] = min( a[2][3], a[2][9] + a[9][3] );
            a[2][4] = min( a[2][4], a[2][9] + a[9][4] );
            a[2][5] = min( a[2][5], a[2][9] + a[9][5] );
            a[2][6] = min( a[2][6], a[2][9] + a[9][6] );
            a[2][7] = min( a[2][7], a[2][9] + a[9][7] );
            a[2][8] = min( a[2][8], a[2][9] + a[9][8] );
            a[2][10] = min( a[2][10], a[2][9] + a[9][10] );
            a[3][1] = min( a[3][1], a[3][9] + a[9][1] );
            a[3][2] = min( a[3][2], a[3][9] + a[9][2] );
            a[3][4] = min( a[3][4], a[3][9] + a[9][4] );
            a[3][5] = min( a[3][5], a[3][9] + a[9][5] );
            a[3][6] = min( a[3][6], a[3][9] + a[9][6] );
            a[3][7] = min( a[3][7], a[3][9] + a[9][7] );
            a[3][8] = min( a[3][8], a[3][9] + a[9][8] );
            a[3][10] = min( a[3][10], a[3][9] + a[9][10] );
            a[4][1] = min( a[4][1], a[4][9] + a[9][1] );
            a[4][2] = min( a[4][2], a[4][9] + a[9][2] );
            a[4][3] = min( a[4][3], a[4][9] + a[9][3] );
            a[4][5] = min( a[4][5], a[4][9] + a[9][5] );
            a[4][6] = min( a[4][6], a[4][9] + a[9][6] );
            a[4][7] = min( a[4][7], a[4][9] + a[9][7] );
            a[4][8] = min( a[4][8], a[4][9] + a[9][8] );
            a[4][10] = min( a[4][10], a[4][9] + a[9][10] );
            a[5][1] = min( a[5][1], a[5][9] + a[9][1] );
            a[5][2] = min( a[5][2], a[5][9] + a[9][2] );
            a[5][3] = min( a[5][3], a[5][9] + a[9][3] );
            a[5][4] = min( a[5][4], a[5][9] + a[9][4] );
            a[5][6] = min( a[5][6], a[5][9] + a[9][6] );
            a[5][7] = min( a[5][7], a[5][9] + a[9][7] );
            a[5][8] = min( a[5][8], a[5][9] + a[9][8] );
            a[5][10] = min( a[5][10], a[5][9] + a[9][10] );
            a[6][1] = min( a[6][1], a[6][9] + a[9][1] );
            a[6][2] = min( a[6][2], a[6][9] + a[9][2] );
            a[6][3] = min( a[6][3], a[6][9] + a[9][3] );
            a[6][4] = min( a[6][4], a[6][9] + a[9][4] );
            a[6][5] = min( a[6][5], a[6][9] + a[9][5] );
            a[6][7] = min( a[6][7], a[6][9] + a[9][7] );
            a[6][8] = min( a[6][8], a[6][9] + a[9][8] );
            a[6][10] = min( a[6][10], a[6][9] + a[9][10] );
            a[7][1] = min( a[7][1], a[7][9] + a[9][1] );
            a[7][2] = min( a[7][2], a[7][9] + a[9][2] );
            a[7][3] = min( a[7][3], a[7][9] + a[9][3] );
            a[7][4] = min( a[7][4], a[7][9] + a[9][4] );
            a[7][5] = min( a[7][5], a[7][9] + a[9][5] );
            a[7][6] = min( a[7][6], a[7][9] + a[9][6] );
            a[7][8] = min( a[7][8], a[7][9] + a[9][8] );
            a[7][10] = min( a[7][10], a[7][9] + a[9][10] );
            a[8][1] = min( a[8][1], a[8][9] + a[9][1] );
            a[8][2] = min( a[8][2], a[8][9] + a[9][2] );
            a[8][3] = min( a[8][3], a[8][9] + a[9][3] );
            a[8][4] = min( a[8][4], a[8][9] + a[9][4] );
            a[8][5] = min( a[8][5], a[8][9] + a[9][5] );
            a[8][6] = min( a[8][6], a[8][9] + a[9][6] );
            a[8][7] = min( a[8][7], a[8][9] + a[9][7] );
            a[8][10] = min( a[8][10], a[8][9] + a[9][10] );
            a[10][1] = min( a[10][1], a[10][9] + a[9][1] );
            a[10][2] = min( a[10][2], a[10][9] + a[9][2] );
            a[10][3] = min( a[10][3], a[10][9] + a[9][3] );
            a[10][4] = min( a[10][4], a[10][9] + a[9][4] );
            a[10][5] = min( a[10][5], a[10][9] + a[9][5] );
            a[10][6] = min( a[10][6], a[10][9] + a[9][6] );
            a[10][7] = min( a[10][7], a[10][9] + a[9][7] );
            a[10][8] = min( a[10][8], a[10][9] + a[9][8] );
            a[1][2] = min( a[1][2], a[1][10] + a[10][2] );
            a[1][3] = min( a[1][3], a[1][10] + a[10][3] );
            a[1][4] = min( a[1][4], a[1][10] + a[10][4] );
            a[1][5] = min( a[1][5], a[1][10] + a[10][5] );
            a[1][6] = min( a[1][6], a[1][10] + a[10][6] );
            a[1][7] = min( a[1][7], a[1][10] + a[10][7] );
            a[1][8] = min( a[1][8], a[1][10] + a[10][8] );
            a[1][9] = min( a[1][9], a[1][10] + a[10][9] );
            a[2][1] = min( a[2][1], a[2][10] + a[10][1] );
            a[2][3] = min( a[2][3], a[2][10] + a[10][3] );
            a[2][4] = min( a[2][4], a[2][10] + a[10][4] );
            a[2][5] = min( a[2][5], a[2][10] + a[10][5] );
            a[2][6] = min( a[2][6], a[2][10] + a[10][6] );
            a[2][7] = min( a[2][7], a[2][10] + a[10][7] );
            a[2][8] = min( a[2][8], a[2][10] + a[10][8] );
            a[2][9] = min( a[2][9], a[2][10] + a[10][9] );
            a[3][1] = min( a[3][1], a[3][10] + a[10][1] );
            a[3][2] = min( a[3][2], a[3][10] + a[10][2] );
            a[3][4] = min( a[3][4], a[3][10] + a[10][4] );
            a[3][5] = min( a[3][5], a[3][10] + a[10][5] );
            a[3][6] = min( a[3][6], a[3][10] + a[10][6] );
            a[3][7] = min( a[3][7], a[3][10] + a[10][7] );
            a[3][8] = min( a[3][8], a[3][10] + a[10][8] );
            a[3][9] = min( a[3][9], a[3][10] + a[10][9] );
            a[4][1] = min( a[4][1], a[4][10] + a[10][1] );
            a[4][2] = min( a[4][2], a[4][10] + a[10][2] );
            a[4][3] = min( a[4][3], a[4][10] + a[10][3] );
            a[4][5] = min( a[4][5], a[4][10] + a[10][5] );
            a[4][6] = min( a[4][6], a[4][10] + a[10][6] );
            a[4][7] = min( a[4][7], a[4][10] + a[10][7] );
            a[4][8] = min( a[4][8], a[4][10] + a[10][8] );
            a[4][9] = min( a[4][9], a[4][10] + a[10][9] );
            a[5][1] = min( a[5][1], a[5][10] + a[10][1] );
            a[5][2] = min( a[5][2], a[5][10] + a[10][2] );
            a[5][3] = min( a[5][3], a[5][10] + a[10][3] );
            a[5][4] = min( a[5][4], a[5][10] + a[10][4] );
            a[5][6] = min( a[5][6], a[5][10] + a[10][6] );
            a[5][7] = min( a[5][7], a[5][10] + a[10][7] );
            a[5][8] = min( a[5][8], a[5][10] + a[10][8] );
            a[5][9] = min( a[5][9], a[5][10] + a[10][9] );
            a[6][1] = min( a[6][1], a[6][10] + a[10][1] );
            a[6][2] = min( a[6][2], a[6][10] + a[10][2] );
            a[6][3] = min( a[6][3], a[6][10] + a[10][3] );
            a[6][4] = min( a[6][4], a[6][10] + a[10][4] );
            a[6][5] = min( a[6][5], a[6][10] + a[10][5] );
            a[6][7] = min( a[6][7], a[6][10] + a[10][7] );
            a[6][8] = min( a[6][8], a[6][10] + a[10][8] );
            a[6][9] = min( a[6][9], a[6][10] + a[10][9] );
            a[7][1] = min( a[7][1], a[7][10] + a[10][1] );
            a[7][2] = min( a[7][2], a[7][10] + a[10][2] );
            a[7][3] = min( a[7][3], a[7][10] + a[10][3] );
            a[7][4] = min( a[7][4], a[7][10] + a[10][4] );
            a[7][5] = min( a[7][5], a[7][10] + a[10][5] );
            a[7][6] = min( a[7][6], a[7][10] + a[10][6] );
            a[7][8] = min( a[7][8], a[7][10] + a[10][8] );
            a[7][9] = min( a[7][9], a[7][10] + a[10][9] );
            a[8][1] = min( a[8][1], a[8][10] + a[10][1] );
            a[8][2] = min( a[8][2], a[8][10] + a[10][2] );
            a[8][3] = min( a[8][3], a[8][10] + a[10][3] );
            a[8][4] = min( a[8][4], a[8][10] + a[10][4] );
            a[8][5] = min( a[8][5], a[8][10] + a[10][5] );
            a[8][6] = min( a[8][6], a[8][10] + a[10][6] );
            a[8][7] = min( a[8][7], a[8][10] + a[10][7] );
            a[8][9] = min( a[8][9], a[8][10] + a[10][9] );
            a[9][1] = min( a[9][1], a[9][10] + a[10][1] );
            a[9][2] = min( a[9][2], a[9][10] + a[10][2] );
            a[9][3] = min( a[9][3], a[9][10] + a[10][3] );
            a[9][4] = min( a[9][4], a[9][10] + a[10][4] );
            a[9][5] = min( a[9][5], a[9][10] + a[10][5] );
            a[9][6] = min( a[9][6], a[9][10] + a[10][6] );
            a[9][7] = min( a[9][7], a[9][10] + a[10][7] );
            a[9][8] = min( a[9][8], a[9][10] + a[10][8] );
            res = ( 1 <= n && 2 <= n ) ? max( res, a[1][2] ) : res;
            res = ( 1 <= n && 3 <= n ) ? max( res, a[1][3] ) : res;
            res = ( 1 <= n && 4 <= n ) ? max( res, a[1][4] ) : res;
            res = ( 1 <= n && 5 <= n ) ? max( res, a[1][5] ) : res;
            res = ( 1 <= n && 6 <= n ) ? max( res, a[1][6] ) : res;
            res = ( 1 <= n && 7 <= n ) ? max( res, a[1][7] ) : res;
            res = ( 1 <= n && 8 <= n ) ? max( res, a[1][8] ) : res;
            res = ( 1 <= n && 9 <= n ) ? max( res, a[1][9] ) : res;
            res = ( 1 <= n && 10 <= n ) ? max( res, a[1][10] ) : res;
            res = ( 2 <= n && 1 <= n ) ? max( res, a[2][1] ) : res;
            res = ( 2 <= n && 3 <= n ) ? max( res, a[2][3] ) : res;
            res = ( 2 <= n && 4 <= n ) ? max( res, a[2][4] ) : res;
            res = ( 2 <= n && 5 <= n ) ? max( res, a[2][5] ) : res;
            res = ( 2 <= n && 6 <= n ) ? max( res, a[2][6] ) : res;
            res = ( 2 <= n && 7 <= n ) ? max( res, a[2][7] ) : res;
            res = ( 2 <= n && 8 <= n ) ? max( res, a[2][8] ) : res;
            res = ( 2 <= n && 9 <= n ) ? max( res, a[2][9] ) : res;
            res = ( 2 <= n && 10 <= n ) ? max( res, a[2][10] ) : res;
            res = ( 3 <= n && 1 <= n ) ? max( res, a[3][1] ) : res;
            res = ( 3 <= n && 2 <= n ) ? max( res, a[3][2] ) : res;
            res = ( 3 <= n && 4 <= n ) ? max( res, a[3][4] ) : res;
            res = ( 3 <= n && 5 <= n ) ? max( res, a[3][5] ) : res;
            res = ( 3 <= n && 6 <= n ) ? max( res, a[3][6] ) : res;
            res = ( 3 <= n && 7 <= n ) ? max( res, a[3][7] ) : res;
            res = ( 3 <= n && 8 <= n ) ? max( res, a[3][8] ) : res;
            res = ( 3 <= n && 9 <= n ) ? max( res, a[3][9] ) : res;
            res = ( 3 <= n && 10 <= n ) ? max( res, a[3][10] ) : res;
            res = ( 4 <= n && 1 <= n ) ? max( res, a[4][1] ) : res;
            res = ( 4 <= n && 2 <= n ) ? max( res, a[4][2] ) : res;
            res = ( 4 <= n && 3 <= n ) ? max( res, a[4][3] ) : res;
            res = ( 4 <= n && 5 <= n ) ? max( res, a[4][5] ) : res;
            res = ( 4 <= n && 6 <= n ) ? max( res, a[4][6] ) : res;
            res = ( 4 <= n && 7 <= n ) ? max( res, a[4][7] ) : res;
            res = ( 4 <= n && 8 <= n ) ? max( res, a[4][8] ) : res;
            res = ( 4 <= n && 9 <= n ) ? max( res, a[4][9] ) : res;
            res = ( 4 <= n && 10 <= n ) ? max( res, a[4][10] ) : res;
            res = ( 5 <= n && 1 <= n ) ? max( res, a[5][1] ) : res;
            res = ( 5 <= n && 2 <= n ) ? max( res, a[5][2] ) : res;
            res = ( 5 <= n && 3 <= n ) ? max( res, a[5][3] ) : res;
            res = ( 5 <= n && 4 <= n ) ? max( res, a[5][4] ) : res;
            res = ( 5 <= n && 6 <= n ) ? max( res, a[5][6] ) : res;
            res = ( 5 <= n && 7 <= n ) ? max( res, a[5][7] ) : res;
            res = ( 5 <= n && 8 <= n ) ? max( res, a[5][8] ) : res;
            res = ( 5 <= n && 9 <= n ) ? max( res, a[5][9] ) : res;
            res = ( 5 <= n && 10 <= n ) ? max( res, a[5][10] ) : res;
            res = ( 6 <= n && 1 <= n ) ? max( res, a[6][1] ) : res;
            res = ( 6 <= n && 2 <= n ) ? max( res, a[6][2] ) : res;
            res = ( 6 <= n && 3 <= n ) ? max( res, a[6][3] ) : res;
            res = ( 6 <= n && 4 <= n ) ? max( res, a[6][4] ) : res;
            res = ( 6 <= n && 5 <= n ) ? max( res, a[6][5] ) : res;
            res = ( 6 <= n && 7 <= n ) ? max( res, a[6][7] ) : res;
            res = ( 6 <= n && 8 <= n ) ? max( res, a[6][8] ) : res;
            res = ( 6 <= n && 9 <= n ) ? max( res, a[6][9] ) : res;
            res = ( 6 <= n && 10 <= n ) ? max( res, a[6][10] ) : res;
            res = ( 7 <= n && 1 <= n ) ? max( res, a[7][1] ) : res;
            res = ( 7 <= n && 2 <= n ) ? max( res, a[7][2] ) : res;
            res = ( 7 <= n && 3 <= n ) ? max( res, a[7][3] ) : res;
            res = ( 7 <= n && 4 <= n ) ? max( res, a[7][4] ) : res;
            res = ( 7 <= n && 5 <= n ) ? max( res, a[7][5] ) : res;
            res = ( 7 <= n && 6 <= n ) ? max( res, a[7][6] ) : res;
            res = ( 7 <= n && 8 <= n ) ? max( res, a[7][8] ) : res;
            res = ( 7 <= n && 9 <= n ) ? max( res, a[7][9] ) : res;
            res = ( 7 <= n && 10 <= n ) ? max( res, a[7][10] ) : res;
            res = ( 8 <= n && 1 <= n ) ? max( res, a[8][1] ) : res;
            res = ( 8 <= n && 2 <= n ) ? max( res, a[8][2] ) : res;
            res = ( 8 <= n && 3 <= n ) ? max( res, a[8][3] ) : res;
            res = ( 8 <= n && 4 <= n ) ? max( res, a[8][4] ) : res;
            res = ( 8 <= n && 5 <= n ) ? max( res, a[8][5] ) : res;
            res = ( 8 <= n && 6 <= n ) ? max( res, a[8][6] ) : res;
            res = ( 8 <= n && 7 <= n ) ? max( res, a[8][7] ) : res;
            res = ( 8 <= n && 9 <= n ) ? max( res, a[8][9] ) : res;
            res = ( 8 <= n && 10 <= n ) ? max( res, a[8][10] ) : res;
            res = ( 9 <= n && 1 <= n ) ? max( res, a[9][1] ) : res;
            res = ( 9 <= n && 2 <= n ) ? max( res, a[9][2] ) : res;
            res = ( 9 <= n && 3 <= n ) ? max( res, a[9][3] ) : res;
            res = ( 9 <= n && 4 <= n ) ? max( res, a[9][4] ) : res;
            res = ( 9 <= n && 5 <= n ) ? max( res, a[9][5] ) : res;
            res = ( 9 <= n && 6 <= n ) ? max( res, a[9][6] ) : res;
            res = ( 9 <= n && 7 <= n ) ? max( res, a[9][7] ) : res;
            res = ( 9 <= n && 8 <= n ) ? max( res, a[9][8] ) : res;
            res = ( 9 <= n && 10 <= n ) ? max( res, a[9][10] ) : res;
            res = ( 10 <= n && 1 <= n ) ? max( res, a[10][1] ) : res;
            res = ( 10 <= n && 2 <= n ) ? max( res, a[10][2] ) : res;
            res = ( 10 <= n && 3 <= n ) ? max( res, a[10][3] ) : res;
            res = ( 10 <= n && 4 <= n ) ? max( res, a[10][4] ) : res;
            res = ( 10 <= n && 5 <= n ) ? max( res, a[10][5] ) : res;
            res = ( 10 <= n && 6 <= n ) ? max( res, a[10][6] ) : res;
            res = ( 10 <= n && 7 <= n ) ? max( res, a[10][7] ) : res;
            res = ( 10 <= n && 8 <= n ) ? max( res, a[10][8] ) : res;
            res = ( 10 <= n && 9 <= n ) ? max( res, a[10][9] ) : res;

            cout << res;

      }

};

int main() {

	//faster_io;

	Main::run();

	return 0;

}

#include <bits/stdc++.h>
using namespace std;
int dis[20][20];
int n;
int Floyd(int n)
{
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			ans=max(ans,dis[i][j]);
	return ans;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>dis[i][j];
	cout<<Floyd(n)<<"\n";
}

#include <bits/stdc++.h>
using namespace std;

int g[11][11];
int n;
int ans = 0;

int _w(int i, int j, int k);

int war(int i, int j, int k){
    return (i == n) ? 1 : k == n ? war(i, j+1, 0) : j == n ? war(i+1, 0, 0) : _w(i,j,k);
}

int _r(int i, int j);

int readg(int i, int j){
    return i == n ? 1 : j == n ? readg(i+1, 0) : _r(i,j);
}

int t = 0;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    readg(0, 0);
    war(0,0,0);
    t = 1;
    war(0,0,0);
    cout << ans;
    return 0;
}

int _w(int i, int j, int k){
    g[i][j] = min(g[i][k] + g[k][j], g[i][j]);
    ans = t? max(ans, g[i][j]) : 0;
    war(i, j, k+1);
}

int _r(int i, int j){
    cin >> g[i][j];
    readg(i, j+1);
}

#include<algorithm>
#include<cstdio>
#define Re register int
using namespace std;
const int N=12;
int n,ans,a[N][N],dis[N][N];
inline void in(Re &x){
    int f=0;x=0;char c=getchar();
    while(c<'0'||c>'9')f|=c=='-',c=getchar();
    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
    x=f?-x:x;
}
int main(){
    in(n);
f\
o\
r(Re i=1;i<=n;++i)
f\
o\
r(Re j=1;j<=n;++j)
    in(a[i][j]),dis[i][j]=a[i][j];
f\
o\
r(Re k=1;k<=n;++k)
f\
o\
r(Re i=1;i<=n;++i)
f\
o\
r(Re j=1;j<=n;++j)
    if(a[k][j])dis[i][j]=min(dis[i][j],dis[i][k]+a[k][j]);
f\
o\
r(Re i=1;i<=n;++i)
f\
o\
r(Re j=1;j<=n;++j)
    if(i!=j)ans=max(ans,dis[i][j]);
    printf("%d\n",ans);
}

#include <bits/stdc++.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327
#endif // M_PI
#define endl "\n"
#define FOR(x, y, z) for (int x = (y); x < (z); ++x)
#define FORR(x, y, z) for (int x = (y); x > (z); --x)
#define GET(a, n) for (int __i = 0; __i < (n); ++__i) cin >> a[__i];
#define GETM(a, n, m) for (int __i = 0; __i < (n); ++__i) for (int __j = 0; __j < m; ++__j) cin >> a[__i][__j];
#define PRINTM(a, n, m) for (int __i = 0; __i < (n); ++__i) { for (int __j = 0; __j < m; ++__j) cout << a[__i][__j] << " ";  cout << endl; };
#define PRINT(a, n) for (int __i = 0; __i < (n); ++__i) cout << a[__i] << " ";
#define IT(a) a.begin(), a.end()
#define SQR(x) (x) * (x)
#define CASE(a, s) cout << "Case #" << a << ": " << s << endl;
#define DEB(a) cout << #a << " = " << (a) << endl; cout.flush();
#define DEBA(a) for (auto __i: a) cout << __i << " "; cout << endl; cout.flush();
#define IFDEB(b, a) if (b) { cout << #a << " = " << (a) << endl; cout.flush(); }
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;
const int MOD = 1000000007;
struct Sync_stdio { Sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(false); } } _sync_stdio;

int main()
{
    int n;
    cin >> n;
    vector <vector <int>> v(n, vector <int> (n));
    GETM(v, n, n);
    FOR (k, 0, n) {
        FOR (i, 0, n) {
            FOR (j, 0, n) {
                v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
            }
        }
    }
    int res = 0;
    FOR (i, 0, n) {
        FOR (j, 0, n) {
            if (i == j) {
                continue;
            }
            res = max(res, v[i][j]);
        }
    }
    cout << res;
}

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[101][101],n,ans=0;
int main()
{
    cin>>n;
 for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
        cin>>a[i][j];
 for(int k=1;k<=n;k++)
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
 for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
        ans=max(ans,a[i][j]);
    cout<<ans<<endl;
    return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;
int E[20][20];
int main()
{
int n,ans=0;
scanf("%d",&n);
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j) scanf("%d",&E[i][j]);
for(int k=1;k<=n;++k)
for (int i=1;i<=n;++i)
for (int j=1;j<=n;++j)
E[i][j]=min(E[i][j],E[i][k]+E[k][j]);
for (int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
ans=max(ans,E[i][j]);
printf("%d",ans);
return 0;
}

#include<bits/stdc++.h>\#\
define fr f\
          o\
          r
using namespace std;
int E[20][20],n,ans=0;
int main() {
	scanf("%d",&n);
	fr (int i=0; i<n; i++)
		fr (int j=0; j<n; j++)
			scanf("%d",E[i]+j);
	fr (int k=0; k<n; k++)
		fr (int i=0; i<n; i++)
			fr (int j=0; j<n; j++)
				E[i][j]=min(E[i][j],E[i][k]+E[k][j]);
	fr (int i=0; i<n; i++)
		fr (int j=0; j<n; j++)
			ans=max(ans,E[i][j]);
	printf("%d",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 2e2 + 17;

ll n, a[MAXN][MAXN], dp[MAXN][MAXN];
map<int, int> mp;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			cin >> a[i][j], dp[i][j] = a[i][j];
	/
	for (int k = 1; k <= n; k++)
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			ans = max(ans, dp[i][j]);
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;

int m[20][20];
int ans[20][20];

int main() {
  int n;
  cin >> n;

  fo\
r (int i = 0; i < n; i++) {
    fo\
r (int j = 0; j < n; j++) {
      cin >> m[i][j];
      ans[i][j] = m[i][j];
    }
  }

  fo\
r (int i = 0; i < n; i++) {
    fo\
r (int j = 0; j < n; j++) {
      fo\
r (int k = 0; k < n; k++) {
        ans[i][j] = ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j]);
      }
    }
  }

  int annn = 0;
  fo\
r (int i = 0; i < n; i++) {
    fo\
r (int j = 0; j < n; j++) {
      annn = max(annn, ans[i][j]);
    }
  }
  cout << annn << endl;

  return 0;
}

#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <string.h>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define INF 1000000
#define MAX 500000
#define pb push_back
#define mp make_pair
#define UNVISITED 0
#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
using namespace std;
typedef long long int ll;
typedef vector <ll> vi;
typedef pair<ll,string> ii;
typedef vector<ii> vii;

int main()
{
 // freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
 ll V;
 ll arr[100][100];
 cin>>V;
 FOR(i,V)
 {
FOR(j,V)
  cin>>arr[i][j];
 }
FOR(k,V)
 {
  FOR(i,V)
  {
    FOR(j,V)
      arr[i][j]=min(arr[i][j],arr[i][k]+arr[k][j]);
  }
 }

 ll minn=0;
 FOR(i,V)
 {
  FOR(j,V)
  {
    if(minn<arr[i][j])
      minn=arr[i][j];
  }
 }
 cout<<minn;
  return 0;
}

#include<bits/stdc++.h>

using namespace std;

const int N=1e5+5;
const int mod=1e9+7;
const int inf=1e9+7;

int i,j,n,s,ans;
int A[15][15];

int scan(){
	scanf("%d",A[i]+j);
	A[i][j]=(A[i][j]==0?inf/3:A[i][j]);
	A[i][j]=(i==j?0:A[i][j]);
	s++;
	j++;
	i+=(j==n+1?1:0);
	j=(j==n+1?1:j);
	return s==n*n?1:scan();
}

int first(int x);
int second(int x,int y);
int third(int x,int y,int z);

int ssecond(int x,int y);

int third(int x,int y,int z){
	A[x][y]=(z==n+1?A[x][y]:min(A[x][y],A[x][z]+A[z][y]));
	return z==n+1?second(x,y+1):third(x,y,z+1);
}

int second(int x,int y){
	return y==n+1?first(x+1):third(x,y,1);
}

int first(int x){
	return x==n+1?1:second(x,1);
}

int sfirst(int x){
	return x==n+1?1:ssecond(x,1);
}

int ssecond(int x,int y){
	ans=(y==n+1?ans:(A[x][y]>=inf/3?ans:max(ans,A[x][y])));
	return y==n+1?sfirst(x+1):ssecond(x,y+1);
}

main(){

	scanf("%d",&n);

	i=1;
	j=1;

	scan();

	first(1);

	sfirst(1);

	printf("%d",ans);
}

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        if (a[i][k] + a[k][j] < a[i][j])
          a[i][j] = a[i][k] + a[k][j];

  int ans = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (a[i][j] > ans) ans = a[i][j];
    }
  }

  cout << ans;

  return 0;
}

#include <bits/stdc++.h>
#define INF 99999
using namespace std;

int main()
{
    int n;
	cin >> n;

	int grid[18][18];
	memset(grid,0,sizeof grid);
    for (int i=0;i<n;i++) {
        for (int j=0;j<n;j++) {
            cin >> grid[i][j];
        }
    }

    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (grid[i][k] + grid[k][j] < grid[i][j])
                    grid[i][j] = grid[i][k] + grid[k][j];
            }
        }
    }

    int ans = -1e8;
    for (int i=0;i<n;i++) {
        for (int j=0;j<n;j++) {
            ans = max(ans, grid[i][j]);
        }
    }

    cout << ans << endl;

	return 0;
}

#include<bits/stdc++.h>

int n, a[15][15];

int scan(int i, int j, int n) {
	scanf("%d", &a[i][j]);
	return j + 1 < n ? scan(i, j + 1, n) : i + 1 < n ? scan(i + 1, 0, n) : 0;
}

int wtf(int i, int j, int k, int n) {
	a[i][j] = std::min(a[i][j], a[j][i] + a[i][k]);
	return k + 1 < n ? wtf(i, j, k + 1, n) : j + 1 < n ? wtf(i, j + 1, 0, n) : i + 1 < n ? wtf(i + 1, 0, 0, n) : 0;
}

int ftw(int i, int j, int n) {
	return std::max(a[i][j], j + 1 < n ? ftw(i, j + 1, n) : i + 1 < n ? ftw(i + 1, 0, n) : 0);
}

int main() {
	scanf("%d", &n);
	scan(0, 0, n);
	wtf(0, 0, 0, n);
	printf("%d\n", ftw(0, 0, n));
	scanf("\n");
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int const MAX_N = 128 * 2;
long long const LL_INF = 1000000000000000009LL;
long long const MOD = 1000000007LL;

double pp = 1.6180339887498948482;

int const MX = 15000000;
int m[1000],r[1000];

long long sm[100][100],d[100];
int nnew[100];

int main() {
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int n;
	cin>>n;
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			cin>>sm[i][j];
	long long ans = 0LL;
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++) {
			for (int k=0; k<n; k++) d[k] = LL_INF;
			d[i] = 0;
			for (int k=0; k<n; k++) nnew[k] = 0;
			while (1) {
				long long mn = LL_INF;
				int p = -1;
				for (int k=0; k<n; k++)
					if (!nnew[k] && d[k] < mn) {
						mn = d[k];
						p = k;
					}
				if (p<0) break;
				nnew[p] = 1;
				for (int k=0; k<n; k++)
					if (d[k] > d[p] + sm[p][k])
						d[k] = d[p] + sm[p][k];
			}
			ans = max(ans,d[j]);
		}
	cout<<ans;
	return 0;
}

//God & me
//Damned if Amirjoon doesn't take what he wants.
#include <bits/stdc++.h>
using namespace std;

const int maxn=2e1+17;
int n,w[maxn][maxn];
void DeemoLovesInit(){
    int i=0;
 getinp:
    i == n*n ? 17 : ({
	    cin>>w[i/n][i%n];
	    i++;
	    goto getinp;
	    17;
	});
}
void make_amirjoon_happy(){
    int k=0;
 K:
    k == n ? 17 : ({
	    int i=0;
	I:
	    i == n ? 17 : ({
		    int j=0;
		J:
		    j == n ? 17 : ({
			    w[i][j] = w[i][j] > w[i][k] + w[k][j] ? w[i][k] + w[k][j] : w[i][j];
			    j++;
			    goto J;
			    17;
			});
		    i++;
		    goto I;
		    17;
		});
	    k++;
	    goto K;
	    17;
	});
}
int ans=0;
void hamid(){
    int i=0;
 getans:
    i == n*n ? 17 : ({
	    ans = ans > w[i/n][i%n] ? ans : w[i/n][i%n];
	    i++;
	    goto getans;
	    17;
	});
}
main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n;
    DeemoLovesInit();
    make_amirjoon_happy();
    hamid();
    cout<<ans<<'\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int a[12][12];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    for(int j=1; j<=n; j++)
    scanf("%d",&a[i][j]);
    for(int k=1; k<=n; k++)
    {
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                a[i][j] = min(a[i][j],a[i][k]+a[k][j]);
            }
        }
    }
    int ans=0;
    for(int i=1; i<=n; i++)
    for(int j=1; j<=n; j++)
    ans=max(ans,a[i][j]);
    cout<<ans<<endl;
    return 0;
}

#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <algorithm>

using namespace std;

int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
int k;
int l;
int m;
int n;
int o;
int p;
int q;
int r;
int s;
int t;
int u;
int v;
int w;
int x;
int y;
int z;
int A;
int B;
int C;
int D;
int E;
int F;
int G;
int H;
int I;
int J;
int K;
int L;
int M;
int N;
int O;
int P;
int Q;
int R;
int S;
int T;
int U;
int V;
int W;
int X;
int Y;
int Z;
int a0;
int b0;
int c0;
int d0;
int e0;
int f0;
int g0;
int h0;
int i0;
int j0;
int k0;
int l0;
int m0;
int n0;
int o0;
int p0;
int q0;
int r0;
int s0;
int t0;
int u0;
int v0;
int w0;
int x0;
int y0;
int z0;
int A0;
int B0;
int C0;
int D0;
int E0;
int F0;
int G0;
int H0;
int I0;
int J0;
int K0;
int L0;
int M0;
int N0;
int O0;
int P0;
int Q0;
int R0;
int S0;
int T0;
int U0;
int V0;

int _n;

void solve1() {
	a=min(a,a+a);
	int _a=0;
	_a=max(_a,a);
	printf("%d\n", _a);
}

void solve2() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,c+a);
	d=min(d,c+b);
	a=min(a,b+c);
	b=min(b,b+d);
	c=min(c,d+c);
	d=min(d,d+d);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	printf("%d\n", _a);
}

void solve3() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,a+c);
	d=min(d,d+a);
	e=min(e,d+b);
	f=min(f,d+c);
	g=min(g,g+a);
	h=min(h,g+b);
	i=min(i,g+c);
	a=min(a,b+d);
	b=min(b,b+e);
	c=min(c,b+f);
	d=min(d,e+d);
	e=min(e,e+e);
	f=min(f,e+f);
	g=min(g,h+d);
	h=min(h,h+e);
	i=min(i,h+f);
	a=min(a,c+g);
	b=min(b,c+h);
	c=min(c,c+i);
	d=min(d,f+g);
	e=min(e,f+h);
	f=min(f,f+i);
	g=min(g,i+g);
	h=min(h,i+h);
	i=min(i,i+i);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	_a=max(_a,e);
	_a=max(_a,f);
	_a=max(_a,g);
	_a=max(_a,h);
	_a=max(_a,i);
	printf("%d\n", _a);
}

void solve4() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,a+c);
	d=min(d,a+d);
	e=min(e,e+a);
	f=min(f,e+b);
	g=min(g,e+c);
	h=min(h,e+d);
	i=min(i,i+a);
	j=min(j,i+b);
	k=min(k,i+c);
	l=min(l,i+d);
	m=min(m,m+a);
	n=min(n,m+b);
	o=min(o,m+c);
	p=min(p,m+d);
	a=min(a,b+e);
	b=min(b,b+f);
	c=min(c,b+g);
	d=min(d,b+h);
	e=min(e,f+e);
	f=min(f,f+f);
	g=min(g,f+g);
	h=min(h,f+h);
	i=min(i,j+e);
	j=min(j,j+f);
	k=min(k,j+g);
	l=min(l,j+h);
	m=min(m,n+e);
	n=min(n,n+f);
	o=min(o,n+g);
	p=min(p,n+h);
	a=min(a,c+i);
	b=min(b,c+j);
	c=min(c,c+k);
	d=min(d,c+l);
	e=min(e,g+i);
	f=min(f,g+j);
	g=min(g,g+k);
	h=min(h,g+l);
	i=min(i,k+i);
	j=min(j,k+j);
	k=min(k,k+k);
	l=min(l,k+l);
	m=min(m,o+i);
	n=min(n,o+j);
	o=min(o,o+k);
	p=min(p,o+l);
	a=min(a,d+m);
	b=min(b,d+n);
	c=min(c,d+o);
	d=min(d,d+p);
	e=min(e,h+m);
	f=min(f,h+n);
	g=min(g,h+o);
	h=min(h,h+p);
	i=min(i,l+m);
	j=min(j,l+n);
	k=min(k,l+o);
	l=min(l,l+p);
	m=min(m,p+m);
	n=min(n,p+n);
	o=min(o,p+o);
	p=min(p,p+p);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	_a=max(_a,e);
	_a=max(_a,f);
	_a=max(_a,g);
	_a=max(_a,h);
	_a=max(_a,i);
	_a=max(_a,j);
	_a=max(_a,k);
	_a=max(_a,l);
	_a=max(_a,m);
	_a=max(_a,n);
	_a=max(_a,o);
	_a=max(_a,p);
	printf("%d\n", _a);
}

void solve5() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,a+c);
	d=min(d,a+d);
	e=min(e,a+e);
	f=min(f,f+a);
	g=min(g,f+b);
	h=min(h,f+c);
	i=min(i,f+d);
	j=min(j,f+e);
	k=min(k,k+a);
	l=min(l,k+b);
	m=min(m,k+c);
	n=min(n,k+d);
	o=min(o,k+e);
	p=min(p,p+a);
	q=min(q,p+b);
	r=min(r,p+c);
	s=min(s,p+d);
	t=min(t,p+e);
	u=min(u,u+a);
	v=min(v,u+b);
	w=min(w,u+c);
	x=min(x,u+d);
	y=min(y,u+e);
	a=min(a,b+f);
	b=min(b,b+g);
	c=min(c,b+h);
	d=min(d,b+i);
	e=min(e,b+j);
	f=min(f,g+f);
	g=min(g,g+g);
	h=min(h,g+h);
	i=min(i,g+i);
	j=min(j,g+j);
	k=min(k,l+f);
	l=min(l,l+g);
	m=min(m,l+h);
	n=min(n,l+i);
	o=min(o,l+j);
	p=min(p,q+f);
	q=min(q,q+g);
	r=min(r,q+h);
	s=min(s,q+i);
	t=min(t,q+j);
	u=min(u,v+f);
	v=min(v,v+g);
	w=min(w,v+h);
	x=min(x,v+i);
	y=min(y,v+j);
	a=min(a,c+k);
	b=min(b,c+l);
	c=min(c,c+m);
	d=min(d,c+n);
	e=min(e,c+o);
	f=min(f,h+k);
	g=min(g,h+l);
	h=min(h,h+m);
	i=min(i,h+n);
	j=min(j,h+o);
	k=min(k,m+k);
	l=min(l,m+l);
	m=min(m,m+m);
	n=min(n,m+n);
	o=min(o,m+o);
	p=min(p,r+k);
	q=min(q,r+l);
	r=min(r,r+m);
	s=min(s,r+n);
	t=min(t,r+o);
	u=min(u,w+k);
	v=min(v,w+l);
	w=min(w,w+m);
	x=min(x,w+n);
	y=min(y,w+o);
	a=min(a,d+p);
	b=min(b,d+q);
	c=min(c,d+r);
	d=min(d,d+s);
	e=min(e,d+t);
	f=min(f,i+p);
	g=min(g,i+q);
	h=min(h,i+r);
	i=min(i,i+s);
	j=min(j,i+t);
	k=min(k,n+p);
	l=min(l,n+q);
	m=min(m,n+r);
	n=min(n,n+s);
	o=min(o,n+t);
	p=min(p,s+p);
	q=min(q,s+q);
	r=min(r,s+r);
	s=min(s,s+s);
	t=min(t,s+t);
	u=min(u,x+p);
	v=min(v,x+q);
	w=min(w,x+r);
	x=min(x,x+s);
	y=min(y,x+t);
	a=min(a,e+u);
	b=min(b,e+v);
	c=min(c,e+w);
	d=min(d,e+x);
	e=min(e,e+y);
	f=min(f,j+u);
	g=min(g,j+v);
	h=min(h,j+w);
	i=min(i,j+x);
	j=min(j,j+y);
	k=min(k,o+u);
	l=min(l,o+v);
	m=min(m,o+w);
	n=min(n,o+x);
	o=min(o,o+y);
	p=min(p,t+u);
	q=min(q,t+v);
	r=min(r,t+w);
	s=min(s,t+x);
	t=min(t,t+y);
	u=min(u,y+u);
	v=min(v,y+v);
	w=min(w,y+w);
	x=min(x,y+x);
	y=min(y,y+y);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	_a=max(_a,e);
	_a=max(_a,f);
	_a=max(_a,g);
	_a=max(_a,h);
	_a=max(_a,i);
	_a=max(_a,j);
	_a=max(_a,k);
	_a=max(_a,l);
	_a=max(_a,m);
	_a=max(_a,n);
	_a=max(_a,o);
	_a=max(_a,p);
	_a=max(_a,q);
	_a=max(_a,r);
	_a=max(_a,s);
	_a=max(_a,t);
	_a=max(_a,u);
	_a=max(_a,v);
	_a=max(_a,w);
	_a=max(_a,x);
	_a=max(_a,y);
	printf("%d\n", _a);
}

void solve6() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,a+c);
	d=min(d,a+d);
	e=min(e,a+e);
	f=min(f,a+f);
	g=min(g,g+a);
	h=min(h,g+b);
	i=min(i,g+c);
	j=min(j,g+d);
	k=min(k,g+e);
	l=min(l,g+f);
	m=min(m,m+a);
	n=min(n,m+b);
	o=min(o,m+c);
	p=min(p,m+d);
	q=min(q,m+e);
	r=min(r,m+f);
	s=min(s,s+a);
	t=min(t,s+b);
	u=min(u,s+c);
	v=min(v,s+d);
	w=min(w,s+e);
	x=min(x,s+f);
	y=min(y,y+a);
	z=min(z,y+b);
	A=min(A,y+c);
	B=min(B,y+d);
	C=min(C,y+e);
	D=min(D,y+f);
	E=min(E,E+a);
	F=min(F,E+b);
	G=min(G,E+c);
	H=min(H,E+d);
	I=min(I,E+e);
	J=min(J,E+f);
	a=min(a,b+g);
	b=min(b,b+h);
	c=min(c,b+i);
	d=min(d,b+j);
	e=min(e,b+k);
	f=min(f,b+l);
	g=min(g,h+g);
	h=min(h,h+h);
	i=min(i,h+i);
	j=min(j,h+j);
	k=min(k,h+k);
	l=min(l,h+l);
	m=min(m,n+g);
	n=min(n,n+h);
	o=min(o,n+i);
	p=min(p,n+j);
	q=min(q,n+k);
	r=min(r,n+l);
	s=min(s,t+g);
	t=min(t,t+h);
	u=min(u,t+i);
	v=min(v,t+j);
	w=min(w,t+k);
	x=min(x,t+l);
	y=min(y,z+g);
	z=min(z,z+h);
	A=min(A,z+i);
	B=min(B,z+j);
	C=min(C,z+k);
	D=min(D,z+l);
	E=min(E,F+g);
	F=min(F,F+h);
	G=min(G,F+i);
	H=min(H,F+j);
	I=min(I,F+k);
	J=min(J,F+l);
	a=min(a,c+m);
	b=min(b,c+n);
	c=min(c,c+o);
	d=min(d,c+p);
	e=min(e,c+q);
	f=min(f,c+r);
	g=min(g,i+m);
	h=min(h,i+n);
	i=min(i,i+o);
	j=min(j,i+p);
	k=min(k,i+q);
	l=min(l,i+r);
	m=min(m,o+m);
	n=min(n,o+n);
	o=min(o,o+o);
	p=min(p,o+p);
	q=min(q,o+q);
	r=min(r,o+r);
	s=min(s,u+m);
	t=min(t,u+n);
	u=min(u,u+o);
	v=min(v,u+p);
	w=min(w,u+q);
	x=min(x,u+r);
	y=min(y,A+m);
	z=min(z,A+n);
	A=min(A,A+o);
	B=min(B,A+p);
	C=min(C,A+q);
	D=min(D,A+r);
	E=min(E,G+m);
	F=min(F,G+n);
	G=min(G,G+o);
	H=min(H,G+p);
	I=min(I,G+q);
	J=min(J,G+r);
	a=min(a,d+s);
	b=min(b,d+t);
	c=min(c,d+u);
	d=min(d,d+v);
	e=min(e,d+w);
	f=min(f,d+x);
	g=min(g,j+s);
	h=min(h,j+t);
	i=min(i,j+u);
	j=min(j,j+v);
	k=min(k,j+w);
	l=min(l,j+x);
	m=min(m,p+s);
	n=min(n,p+t);
	o=min(o,p+u);
	p=min(p,p+v);
	q=min(q,p+w);
	r=min(r,p+x);
	s=min(s,v+s);
	t=min(t,v+t);
	u=min(u,v+u);
	v=min(v,v+v);
	w=min(w,v+w);
	x=min(x,v+x);
	y=min(y,B+s);
	z=min(z,B+t);
	A=min(A,B+u);
	B=min(B,B+v);
	C=min(C,B+w);
	D=min(D,B+x);
	E=min(E,H+s);
	F=min(F,H+t);
	G=min(G,H+u);
	H=min(H,H+v);
	I=min(I,H+w);
	J=min(J,H+x);
	a=min(a,e+y);
	b=min(b,e+z);
	c=min(c,e+A);
	d=min(d,e+B);
	e=min(e,e+C);
	f=min(f,e+D);
	g=min(g,k+y);
	h=min(h,k+z);
	i=min(i,k+A);
	j=min(j,k+B);
	k=min(k,k+C);
	l=min(l,k+D);
	m=min(m,q+y);
	n=min(n,q+z);
	o=min(o,q+A);
	p=min(p,q+B);
	q=min(q,q+C);
	r=min(r,q+D);
	s=min(s,w+y);
	t=min(t,w+z);
	u=min(u,w+A);
	v=min(v,w+B);
	w=min(w,w+C);
	x=min(x,w+D);
	y=min(y,C+y);
	z=min(z,C+z);
	A=min(A,C+A);
	B=min(B,C+B);
	C=min(C,C+C);
	D=min(D,C+D);
	E=min(E,I+y);
	F=min(F,I+z);
	G=min(G,I+A);
	H=min(H,I+B);
	I=min(I,I+C);
	J=min(J,I+D);
	a=min(a,f+E);
	b=min(b,f+F);
	c=min(c,f+G);
	d=min(d,f+H);
	e=min(e,f+I);
	f=min(f,f+J);
	g=min(g,l+E);
	h=min(h,l+F);
	i=min(i,l+G);
	j=min(j,l+H);
	k=min(k,l+I);
	l=min(l,l+J);
	m=min(m,r+E);
	n=min(n,r+F);
	o=min(o,r+G);
	p=min(p,r+H);
	q=min(q,r+I);
	r=min(r,r+J);
	s=min(s,x+E);
	t=min(t,x+F);
	u=min(u,x+G);
	v=min(v,x+H);
	w=min(w,x+I);
	x=min(x,x+J);
	y=min(y,D+E);
	z=min(z,D+F);
	A=min(A,D+G);
	B=min(B,D+H);
	C=min(C,D+I);
	D=min(D,D+J);
	E=min(E,J+E);
	F=min(F,J+F);
	G=min(G,J+G);
	H=min(H,J+H);
	I=min(I,J+I);
	J=min(J,J+J);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	_a=max(_a,e);
	_a=max(_a,f);
	_a=max(_a,g);
	_a=max(_a,h);
	_a=max(_a,i);
	_a=max(_a,j);
	_a=max(_a,k);
	_a=max(_a,l);
	_a=max(_a,m);
	_a=max(_a,n);
	_a=max(_a,o);
	_a=max(_a,p);
	_a=max(_a,q);
	_a=max(_a,r);
	_a=max(_a,s);
	_a=max(_a,t);
	_a=max(_a,u);
	_a=max(_a,v);
	_a=max(_a,w);
	_a=max(_a,x);
	_a=max(_a,y);
	_a=max(_a,z);
	_a=max(_a,A);
	_a=max(_a,B);
	_a=max(_a,C);
	_a=max(_a,D);
	_a=max(_a,E);
	_a=max(_a,F);
	_a=max(_a,G);
	_a=max(_a,H);
	_a=max(_a,I);
	_a=max(_a,J);
	printf("%d\n", _a);
}

void solve7() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,a+c);
	d=min(d,a+d);
	e=min(e,a+e);
	f=min(f,a+f);
	g=min(g,a+g);
	h=min(h,h+a);
	i=min(i,h+b);
	j=min(j,h+c);
	k=min(k,h+d);
	l=min(l,h+e);
	m=min(m,h+f);
	n=min(n,h+g);
	o=min(o,o+a);
	p=min(p,o+b);
	q=min(q,o+c);
	r=min(r,o+d);
	s=min(s,o+e);
	t=min(t,o+f);
	u=min(u,o+g);
	v=min(v,v+a);
	w=min(w,v+b);
	x=min(x,v+c);
	y=min(y,v+d);
	z=min(z,v+e);
	A=min(A,v+f);
	B=min(B,v+g);
	C=min(C,C+a);
	D=min(D,C+b);
	E=min(E,C+c);
	F=min(F,C+d);
	G=min(G,C+e);
	H=min(H,C+f);
	I=min(I,C+g);
	J=min(J,J+a);
	K=min(K,J+b);
	L=min(L,J+c);
	M=min(M,J+d);
	N=min(N,J+e);
	O=min(O,J+f);
	P=min(P,J+g);
	Q=min(Q,Q+a);
	R=min(R,Q+b);
	S=min(S,Q+c);
	T=min(T,Q+d);
	U=min(U,Q+e);
	V=min(V,Q+f);
	W=min(W,Q+g);
	a=min(a,b+h);
	b=min(b,b+i);
	c=min(c,b+j);
	d=min(d,b+k);
	e=min(e,b+l);
	f=min(f,b+m);
	g=min(g,b+n);
	h=min(h,i+h);
	i=min(i,i+i);
	j=min(j,i+j);
	k=min(k,i+k);
	l=min(l,i+l);
	m=min(m,i+m);
	n=min(n,i+n);
	o=min(o,p+h);
	p=min(p,p+i);
	q=min(q,p+j);
	r=min(r,p+k);
	s=min(s,p+l);
	t=min(t,p+m);
	u=min(u,p+n);
	v=min(v,w+h);
	w=min(w,w+i);
	x=min(x,w+j);
	y=min(y,w+k);
	z=min(z,w+l);
	A=min(A,w+m);
	B=min(B,w+n);
	C=min(C,D+h);
	D=min(D,D+i);
	E=min(E,D+j);
	F=min(F,D+k);
	G=min(G,D+l);
	H=min(H,D+m);
	I=min(I,D+n);
	J=min(J,K+h);
	K=min(K,K+i);
	L=min(L,K+j);
	M=min(M,K+k);
	N=min(N,K+l);
	O=min(O,K+m);
	P=min(P,K+n);
	Q=min(Q,R+h);
	R=min(R,R+i);
	S=min(S,R+j);
	T=min(T,R+k);
	U=min(U,R+l);
	V=min(V,R+m);
	W=min(W,R+n);
	a=min(a,c+o);
	b=min(b,c+p);
	c=min(c,c+q);
	d=min(d,c+r);
	e=min(e,c+s);
	f=min(f,c+t);
	g=min(g,c+u);
	h=min(h,j+o);
	i=min(i,j+p);
	j=min(j,j+q);
	k=min(k,j+r);
	l=min(l,j+s);
	m=min(m,j+t);
	n=min(n,j+u);
	o=min(o,q+o);
	p=min(p,q+p);
	q=min(q,q+q);
	r=min(r,q+r);
	s=min(s,q+s);
	t=min(t,q+t);
	u=min(u,q+u);
	v=min(v,x+o);
	w=min(w,x+p);
	x=min(x,x+q);
	y=min(y,x+r);
	z=min(z,x+s);
	A=min(A,x+t);
	B=min(B,x+u);
	C=min(C,E+o);
	D=min(D,E+p);
	E=min(E,E+q);
	F=min(F,E+r);
	G=min(G,E+s);
	H=min(H,E+t);
	I=min(I,E+u);
	J=min(J,L+o);
	K=min(K,L+p);
	L=min(L,L+q);
	M=min(M,L+r);
	N=min(N,L+s);
	O=min(O,L+t);
	P=min(P,L+u);
	Q=min(Q,S+o);
	R=min(R,S+p);
	S=min(S,S+q);
	T=min(T,S+r);
	U=min(U,S+s);
	V=min(V,S+t);
	W=min(W,S+u);
	a=min(a,d+v);
	b=min(b,d+w);
	c=min(c,d+x);
	d=min(d,d+y);
	e=min(e,d+z);
	f=min(f,d+A);
	g=min(g,d+B);
	h=min(h,k+v);
	i=min(i,k+w);
	j=min(j,k+x);
	k=min(k,k+y);
	l=min(l,k+z);
	m=min(m,k+A);
	n=min(n,k+B);
	o=min(o,r+v);
	p=min(p,r+w);
	q=min(q,r+x);
	r=min(r,r+y);
	s=min(s,r+z);
	t=min(t,r+A);
	u=min(u,r+B);
	v=min(v,y+v);
	w=min(w,y+w);
	x=min(x,y+x);
	y=min(y,y+y);
	z=min(z,y+z);
	A=min(A,y+A);
	B=min(B,y+B);
	C=min(C,F+v);
	D=min(D,F+w);
	E=min(E,F+x);
	F=min(F,F+y);
	G=min(G,F+z);
	H=min(H,F+A);
	I=min(I,F+B);
	J=min(J,M+v);
	K=min(K,M+w);
	L=min(L,M+x);
	M=min(M,M+y);
	N=min(N,M+z);
	O=min(O,M+A);
	P=min(P,M+B);
	Q=min(Q,T+v);
	R=min(R,T+w);
	S=min(S,T+x);
	T=min(T,T+y);
	U=min(U,T+z);
	V=min(V,T+A);
	W=min(W,T+B);
	a=min(a,e+C);
	b=min(b,e+D);
	c=min(c,e+E);
	d=min(d,e+F);
	e=min(e,e+G);
	f=min(f,e+H);
	g=min(g,e+I);
	h=min(h,l+C);
	i=min(i,l+D);
	j=min(j,l+E);
	k=min(k,l+F);
	l=min(l,l+G);
	m=min(m,l+H);
	n=min(n,l+I);
	o=min(o,s+C);
	p=min(p,s+D);
	q=min(q,s+E);
	r=min(r,s+F);
	s=min(s,s+G);
	t=min(t,s+H);
	u=min(u,s+I);
	v=min(v,z+C);
	w=min(w,z+D);
	x=min(x,z+E);
	y=min(y,z+F);
	z=min(z,z+G);
	A=min(A,z+H);
	B=min(B,z+I);
	C=min(C,G+C);
	D=min(D,G+D);
	E=min(E,G+E);
	F=min(F,G+F);
	G=min(G,G+G);
	H=min(H,G+H);
	I=min(I,G+I);
	J=min(J,N+C);
	K=min(K,N+D);
	L=min(L,N+E);
	M=min(M,N+F);
	N=min(N,N+G);
	O=min(O,N+H);
	P=min(P,N+I);
	Q=min(Q,U+C);
	R=min(R,U+D);
	S=min(S,U+E);
	T=min(T,U+F);
	U=min(U,U+G);
	V=min(V,U+H);
	W=min(W,U+I);
	a=min(a,f+J);
	b=min(b,f+K);
	c=min(c,f+L);
	d=min(d,f+M);
	e=min(e,f+N);
	f=min(f,f+O);
	g=min(g,f+P);
	h=min(h,m+J);
	i=min(i,m+K);
	j=min(j,m+L);
	k=min(k,m+M);
	l=min(l,m+N);
	m=min(m,m+O);
	n=min(n,m+P);
	o=min(o,t+J);
	p=min(p,t+K);
	q=min(q,t+L);
	r=min(r,t+M);
	s=min(s,t+N);
	t=min(t,t+O);
	u=min(u,t+P);
	v=min(v,A+J);
	w=min(w,A+K);
	x=min(x,A+L);
	y=min(y,A+M);
	z=min(z,A+N);
	A=min(A,A+O);
	B=min(B,A+P);
	C=min(C,H+J);
	D=min(D,H+K);
	E=min(E,H+L);
	F=min(F,H+M);
	G=min(G,H+N);
	H=min(H,H+O);
	I=min(I,H+P);
	J=min(J,O+J);
	K=min(K,O+K);
	L=min(L,O+L);
	M=min(M,O+M);
	N=min(N,O+N);
	O=min(O,O+O);
	P=min(P,O+P);
	Q=min(Q,V+J);
	R=min(R,V+K);
	S=min(S,V+L);
	T=min(T,V+M);
	U=min(U,V+N);
	V=min(V,V+O);
	W=min(W,V+P);
	a=min(a,g+Q);
	b=min(b,g+R);
	c=min(c,g+S);
	d=min(d,g+T);
	e=min(e,g+U);
	f=min(f,g+V);
	g=min(g,g+W);
	h=min(h,n+Q);
	i=min(i,n+R);
	j=min(j,n+S);
	k=min(k,n+T);
	l=min(l,n+U);
	m=min(m,n+V);
	n=min(n,n+W);
	o=min(o,u+Q);
	p=min(p,u+R);
	q=min(q,u+S);
	r=min(r,u+T);
	s=min(s,u+U);
	t=min(t,u+V);
	u=min(u,u+W);
	v=min(v,B+Q);
	w=min(w,B+R);
	x=min(x,B+S);
	y=min(y,B+T);
	z=min(z,B+U);
	A=min(A,B+V);
	B=min(B,B+W);
	C=min(C,I+Q);
	D=min(D,I+R);
	E=min(E,I+S);
	F=min(F,I+T);
	G=min(G,I+U);
	H=min(H,I+V);
	I=min(I,I+W);
	J=min(J,P+Q);
	K=min(K,P+R);
	L=min(L,P+S);
	M=min(M,P+T);
	N=min(N,P+U);
	O=min(O,P+V);
	P=min(P,P+W);
	Q=min(Q,W+Q);
	R=min(R,W+R);
	S=min(S,W+S);
	T=min(T,W+T);
	U=min(U,W+U);
	V=min(V,W+V);
	W=min(W,W+W);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	_a=max(_a,e);
	_a=max(_a,f);
	_a=max(_a,g);
	_a=max(_a,h);
	_a=max(_a,i);
	_a=max(_a,j);
	_a=max(_a,k);
	_a=max(_a,l);
	_a=max(_a,m);
	_a=max(_a,n);
	_a=max(_a,o);
	_a=max(_a,p);
	_a=max(_a,q);
	_a=max(_a,r);
	_a=max(_a,s);
	_a=max(_a,t);
	_a=max(_a,u);
	_a=max(_a,v);
	_a=max(_a,w);
	_a=max(_a,x);
	_a=max(_a,y);
	_a=max(_a,z);
	_a=max(_a,A);
	_a=max(_a,B);
	_a=max(_a,C);
	_a=max(_a,D);
	_a=max(_a,E);
	_a=max(_a,F);
	_a=max(_a,G);
	_a=max(_a,H);
	_a=max(_a,I);
	_a=max(_a,J);
	_a=max(_a,K);
	_a=max(_a,L);
	_a=max(_a,M);
	_a=max(_a,N);
	_a=max(_a,O);
	_a=max(_a,P);
	_a=max(_a,Q);
	_a=max(_a,R);
	_a=max(_a,S);
	_a=max(_a,T);
	_a=max(_a,U);
	_a=max(_a,V);
	_a=max(_a,W);
	printf("%d\n", _a);
}

void solve8() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,a+c);
	d=min(d,a+d);
	e=min(e,a+e);
	f=min(f,a+f);
	g=min(g,a+g);
	h=min(h,a+h);
	i=min(i,i+a);
	j=min(j,i+b);
	k=min(k,i+c);
	l=min(l,i+d);
	m=min(m,i+e);
	n=min(n,i+f);
	o=min(o,i+g);
	p=min(p,i+h);
	q=min(q,q+a);
	r=min(r,q+b);
	s=min(s,q+c);
	t=min(t,q+d);
	u=min(u,q+e);
	v=min(v,q+f);
	w=min(w,q+g);
	x=min(x,q+h);
	y=min(y,y+a);
	z=min(z,y+b);
	A=min(A,y+c);
	B=min(B,y+d);
	C=min(C,y+e);
	D=min(D,y+f);
	E=min(E,y+g);
	F=min(F,y+h);
	G=min(G,G+a);
	H=min(H,G+b);
	I=min(I,G+c);
	J=min(J,G+d);
	K=min(K,G+e);
	L=min(L,G+f);
	M=min(M,G+g);
	N=min(N,G+h);
	O=min(O,O+a);
	P=min(P,O+b);
	Q=min(Q,O+c);
	R=min(R,O+d);
	S=min(S,O+e);
	T=min(T,O+f);
	U=min(U,O+g);
	V=min(V,O+h);
	W=min(W,W+a);
	X=min(X,W+b);
	Y=min(Y,W+c);
	Z=min(Z,W+d);
	a0=min(a0,W+e);
	b0=min(b0,W+f);
	c0=min(c0,W+g);
	d0=min(d0,W+h);
	e0=min(e0,e0+a);
	f0=min(f0,e0+b);
	g0=min(g0,e0+c);
	h0=min(h0,e0+d);
	i0=min(i0,e0+e);
	j0=min(j0,e0+f);
	k0=min(k0,e0+g);
	l0=min(l0,e0+h);
	a=min(a,b+i);
	b=min(b,b+j);
	c=min(c,b+k);
	d=min(d,b+l);
	e=min(e,b+m);
	f=min(f,b+n);
	g=min(g,b+o);
	h=min(h,b+p);
	i=min(i,j+i);
	j=min(j,j+j);
	k=min(k,j+k);
	l=min(l,j+l);
	m=min(m,j+m);
	n=min(n,j+n);
	o=min(o,j+o);
	p=min(p,j+p);
	q=min(q,r+i);
	r=min(r,r+j);
	s=min(s,r+k);
	t=min(t,r+l);
	u=min(u,r+m);
	v=min(v,r+n);
	w=min(w,r+o);
	x=min(x,r+p);
	y=min(y,z+i);
	z=min(z,z+j);
	A=min(A,z+k);
	B=min(B,z+l);
	C=min(C,z+m);
	D=min(D,z+n);
	E=min(E,z+o);
	F=min(F,z+p);
	G=min(G,H+i);
	H=min(H,H+j);
	I=min(I,H+k);
	J=min(J,H+l);
	K=min(K,H+m);
	L=min(L,H+n);
	M=min(M,H+o);
	N=min(N,H+p);
	O=min(O,P+i);
	P=min(P,P+j);
	Q=min(Q,P+k);
	R=min(R,P+l);
	S=min(S,P+m);
	T=min(T,P+n);
	U=min(U,P+o);
	V=min(V,P+p);
	W=min(W,X+i);
	X=min(X,X+j);
	Y=min(Y,X+k);
	Z=min(Z,X+l);
	a0=min(a0,X+m);
	b0=min(b0,X+n);
	c0=min(c0,X+o);
	d0=min(d0,X+p);
	e0=min(e0,f0+i);
	f0=min(f0,f0+j);
	g0=min(g0,f0+k);
	h0=min(h0,f0+l);
	i0=min(i0,f0+m);
	j0=min(j0,f0+n);
	k0=min(k0,f0+o);
	l0=min(l0,f0+p);
	a=min(a,c+q);
	b=min(b,c+r);
	c=min(c,c+s);
	d=min(d,c+t);
	e=min(e,c+u);
	f=min(f,c+v);
	g=min(g,c+w);
	h=min(h,c+x);
	i=min(i,k+q);
	j=min(j,k+r);
	k=min(k,k+s);
	l=min(l,k+t);
	m=min(m,k+u);
	n=min(n,k+v);
	o=min(o,k+w);
	p=min(p,k+x);
	q=min(q,s+q);
	r=min(r,s+r);
	s=min(s,s+s);
	t=min(t,s+t);
	u=min(u,s+u);
	v=min(v,s+v);
	w=min(w,s+w);
	x=min(x,s+x);
	y=min(y,A+q);
	z=min(z,A+r);
	A=min(A,A+s);
	B=min(B,A+t);
	C=min(C,A+u);
	D=min(D,A+v);
	E=min(E,A+w);
	F=min(F,A+x);
	G=min(G,I+q);
	H=min(H,I+r);
	I=min(I,I+s);
	J=min(J,I+t);
	K=min(K,I+u);
	L=min(L,I+v);
	M=min(M,I+w);
	N=min(N,I+x);
	O=min(O,Q+q);
	P=min(P,Q+r);
	Q=min(Q,Q+s);
	R=min(R,Q+t);
	S=min(S,Q+u);
	T=min(T,Q+v);
	U=min(U,Q+w);
	V=min(V,Q+x);
	W=min(W,Y+q);
	X=min(X,Y+r);
	Y=min(Y,Y+s);
	Z=min(Z,Y+t);
	a0=min(a0,Y+u);
	b0=min(b0,Y+v);
	c0=min(c0,Y+w);
	d0=min(d0,Y+x);
	e0=min(e0,g0+q);
	f0=min(f0,g0+r);
	g0=min(g0,g0+s);
	h0=min(h0,g0+t);
	i0=min(i0,g0+u);
	j0=min(j0,g0+v);
	k0=min(k0,g0+w);
	l0=min(l0,g0+x);
	a=min(a,d+y);
	b=min(b,d+z);
	c=min(c,d+A);
	d=min(d,d+B);
	e=min(e,d+C);
	f=min(f,d+D);
	g=min(g,d+E);
	h=min(h,d+F);
	i=min(i,l+y);
	j=min(j,l+z);
	k=min(k,l+A);
	l=min(l,l+B);
	m=min(m,l+C);
	n=min(n,l+D);
	o=min(o,l+E);
	p=min(p,l+F);
	q=min(q,t+y);
	r=min(r,t+z);
	s=min(s,t+A);
	t=min(t,t+B);
	u=min(u,t+C);
	v=min(v,t+D);
	w=min(w,t+E);
	x=min(x,t+F);
	y=min(y,B+y);
	z=min(z,B+z);
	A=min(A,B+A);
	B=min(B,B+B);
	C=min(C,B+C);
	D=min(D,B+D);
	E=min(E,B+E);
	F=min(F,B+F);
	G=min(G,J+y);
	H=min(H,J+z);
	I=min(I,J+A);
	J=min(J,J+B);
	K=min(K,J+C);
	L=min(L,J+D);
	M=min(M,J+E);
	N=min(N,J+F);
	O=min(O,R+y);
	P=min(P,R+z);
	Q=min(Q,R+A);
	R=min(R,R+B);
	S=min(S,R+C);
	T=min(T,R+D);
	U=min(U,R+E);
	V=min(V,R+F);
	W=min(W,Z+y);
	X=min(X,Z+z);
	Y=min(Y,Z+A);
	Z=min(Z,Z+B);
	a0=min(a0,Z+C);
	b0=min(b0,Z+D);
	c0=min(c0,Z+E);
	d0=min(d0,Z+F);
	e0=min(e0,h0+y);
	f0=min(f0,h0+z);
	g0=min(g0,h0+A);
	h0=min(h0,h0+B);
	i0=min(i0,h0+C);
	j0=min(j0,h0+D);
	k0=min(k0,h0+E);
	l0=min(l0,h0+F);
	a=min(a,e+G);
	b=min(b,e+H);
	c=min(c,e+I);
	d=min(d,e+J);
	e=min(e,e+K);
	f=min(f,e+L);
	g=min(g,e+M);
	h=min(h,e+N);
	i=min(i,m+G);
	j=min(j,m+H);
	k=min(k,m+I);
	l=min(l,m+J);
	m=min(m,m+K);
	n=min(n,m+L);
	o=min(o,m+M);
	p=min(p,m+N);
	q=min(q,u+G);
	r=min(r,u+H);
	s=min(s,u+I);
	t=min(t,u+J);
	u=min(u,u+K);
	v=min(v,u+L);
	w=min(w,u+M);
	x=min(x,u+N);
	y=min(y,C+G);
	z=min(z,C+H);
	A=min(A,C+I);
	B=min(B,C+J);
	C=min(C,C+K);
	D=min(D,C+L);
	E=min(E,C+M);
	F=min(F,C+N);
	G=min(G,K+G);
	H=min(H,K+H);
	I=min(I,K+I);
	J=min(J,K+J);
	K=min(K,K+K);
	L=min(L,K+L);
	M=min(M,K+M);
	N=min(N,K+N);
	O=min(O,S+G);
	P=min(P,S+H);
	Q=min(Q,S+I);
	R=min(R,S+J);
	S=min(S,S+K);
	T=min(T,S+L);
	U=min(U,S+M);
	V=min(V,S+N);
	W=min(W,a0+G);
	X=min(X,a0+H);
	Y=min(Y,a0+I);
	Z=min(Z,a0+J);
	a0=min(a0,a0+K);
	b0=min(b0,a0+L);
	c0=min(c0,a0+M);
	d0=min(d0,a0+N);
	e0=min(e0,i0+G);
	f0=min(f0,i0+H);
	g0=min(g0,i0+I);
	h0=min(h0,i0+J);
	i0=min(i0,i0+K);
	j0=min(j0,i0+L);
	k0=min(k0,i0+M);
	l0=min(l0,i0+N);
	a=min(a,f+O);
	b=min(b,f+P);
	c=min(c,f+Q);
	d=min(d,f+R);
	e=min(e,f+S);
	f=min(f,f+T);
	g=min(g,f+U);
	h=min(h,f+V);
	i=min(i,n+O);
	j=min(j,n+P);
	k=min(k,n+Q);
	l=min(l,n+R);
	m=min(m,n+S);
	n=min(n,n+T);
	o=min(o,n+U);
	p=min(p,n+V);
	q=min(q,v+O);
	r=min(r,v+P);
	s=min(s,v+Q);
	t=min(t,v+R);
	u=min(u,v+S);
	v=min(v,v+T);
	w=min(w,v+U);
	x=min(x,v+V);
	y=min(y,D+O);
	z=min(z,D+P);
	A=min(A,D+Q);
	B=min(B,D+R);
	C=min(C,D+S);
	D=min(D,D+T);
	E=min(E,D+U);
	F=min(F,D+V);
	G=min(G,L+O);
	H=min(H,L+P);
	I=min(I,L+Q);
	J=min(J,L+R);
	K=min(K,L+S);
	L=min(L,L+T);
	M=min(M,L+U);
	N=min(N,L+V);
	O=min(O,T+O);
	P=min(P,T+P);
	Q=min(Q,T+Q);
	R=min(R,T+R);
	S=min(S,T+S);
	T=min(T,T+T);
	U=min(U,T+U);
	V=min(V,T+V);
	W=min(W,b0+O);
	X=min(X,b0+P);
	Y=min(Y,b0+Q);
	Z=min(Z,b0+R);
	a0=min(a0,b0+S);
	b0=min(b0,b0+T);
	c0=min(c0,b0+U);
	d0=min(d0,b0+V);
	e0=min(e0,j0+O);
	f0=min(f0,j0+P);
	g0=min(g0,j0+Q);
	h0=min(h0,j0+R);
	i0=min(i0,j0+S);
	j0=min(j0,j0+T);
	k0=min(k0,j0+U);
	l0=min(l0,j0+V);
	a=min(a,g+W);
	b=min(b,g+X);
	c=min(c,g+Y);
	d=min(d,g+Z);
	e=min(e,g+a0);
	f=min(f,g+b0);
	g=min(g,g+c0);
	h=min(h,g+d0);
	i=min(i,o+W);
	j=min(j,o+X);
	k=min(k,o+Y);
	l=min(l,o+Z);
	m=min(m,o+a0);
	n=min(n,o+b0);
	o=min(o,o+c0);
	p=min(p,o+d0);
	q=min(q,w+W);
	r=min(r,w+X);
	s=min(s,w+Y);
	t=min(t,w+Z);
	u=min(u,w+a0);
	v=min(v,w+b0);
	w=min(w,w+c0);
	x=min(x,w+d0);
	y=min(y,E+W);
	z=min(z,E+X);
	A=min(A,E+Y);
	B=min(B,E+Z);
	C=min(C,E+a0);
	D=min(D,E+b0);
	E=min(E,E+c0);
	F=min(F,E+d0);
	G=min(G,M+W);
	H=min(H,M+X);
	I=min(I,M+Y);
	J=min(J,M+Z);
	K=min(K,M+a0);
	L=min(L,M+b0);
	M=min(M,M+c0);
	N=min(N,M+d0);
	O=min(O,U+W);
	P=min(P,U+X);
	Q=min(Q,U+Y);
	R=min(R,U+Z);
	S=min(S,U+a0);
	T=min(T,U+b0);
	U=min(U,U+c0);
	V=min(V,U+d0);
	W=min(W,c0+W);
	X=min(X,c0+X);
	Y=min(Y,c0+Y);
	Z=min(Z,c0+Z);
	a0=min(a0,c0+a0);
	b0=min(b0,c0+b0);
	c0=min(c0,c0+c0);
	d0=min(d0,c0+d0);
	e0=min(e0,k0+W);
	f0=min(f0,k0+X);
	g0=min(g0,k0+Y);
	h0=min(h0,k0+Z);
	i0=min(i0,k0+a0);
	j0=min(j0,k0+b0);
	k0=min(k0,k0+c0);
	l0=min(l0,k0+d0);
	a=min(a,h+e0);
	b=min(b,h+f0);
	c=min(c,h+g0);
	d=min(d,h+h0);
	e=min(e,h+i0);
	f=min(f,h+j0);
	g=min(g,h+k0);
	h=min(h,h+l0);
	i=min(i,p+e0);
	j=min(j,p+f0);
	k=min(k,p+g0);
	l=min(l,p+h0);
	m=min(m,p+i0);
	n=min(n,p+j0);
	o=min(o,p+k0);
	p=min(p,p+l0);
	q=min(q,x+e0);
	r=min(r,x+f0);
	s=min(s,x+g0);
	t=min(t,x+h0);
	u=min(u,x+i0);
	v=min(v,x+j0);
	w=min(w,x+k0);
	x=min(x,x+l0);
	y=min(y,F+e0);
	z=min(z,F+f0);
	A=min(A,F+g0);
	B=min(B,F+h0);
	C=min(C,F+i0);
	D=min(D,F+j0);
	E=min(E,F+k0);
	F=min(F,F+l0);
	G=min(G,N+e0);
	H=min(H,N+f0);
	I=min(I,N+g0);
	J=min(J,N+h0);
	K=min(K,N+i0);
	L=min(L,N+j0);
	M=min(M,N+k0);
	N=min(N,N+l0);
	O=min(O,V+e0);
	P=min(P,V+f0);
	Q=min(Q,V+g0);
	R=min(R,V+h0);
	S=min(S,V+i0);
	T=min(T,V+j0);
	U=min(U,V+k0);
	V=min(V,V+l0);
	W=min(W,d0+e0);
	X=min(X,d0+f0);
	Y=min(Y,d0+g0);
	Z=min(Z,d0+h0);
	a0=min(a0,d0+i0);
	b0=min(b0,d0+j0);
	c0=min(c0,d0+k0);
	d0=min(d0,d0+l0);
	e0=min(e0,l0+e0);
	f0=min(f0,l0+f0);
	g0=min(g0,l0+g0);
	h0=min(h0,l0+h0);
	i0=min(i0,l0+i0);
	j0=min(j0,l0+j0);
	k0=min(k0,l0+k0);
	l0=min(l0,l0+l0);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	_a=max(_a,e);
	_a=max(_a,f);
	_a=max(_a,g);
	_a=max(_a,h);
	_a=max(_a,i);
	_a=max(_a,j);
	_a=max(_a,k);
	_a=max(_a,l);
	_a=max(_a,m);
	_a=max(_a,n);
	_a=max(_a,o);
	_a=max(_a,p);
	_a=max(_a,q);
	_a=max(_a,r);
	_a=max(_a,s);
	_a=max(_a,t);
	_a=max(_a,u);
	_a=max(_a,v);
	_a=max(_a,w);
	_a=max(_a,x);
	_a=max(_a,y);
	_a=max(_a,z);
	_a=max(_a,A);
	_a=max(_a,B);
	_a=max(_a,C);
	_a=max(_a,D);
	_a=max(_a,E);
	_a=max(_a,F);
	_a=max(_a,G);
	_a=max(_a,H);
	_a=max(_a,I);
	_a=max(_a,J);
	_a=max(_a,K);
	_a=max(_a,L);
	_a=max(_a,M);
	_a=max(_a,N);
	_a=max(_a,O);
	_a=max(_a,P);
	_a=max(_a,Q);
	_a=max(_a,R);
	_a=max(_a,S);
	_a=max(_a,T);
	_a=max(_a,U);
	_a=max(_a,V);
	_a=max(_a,W);
	_a=max(_a,X);
	_a=max(_a,Y);
	_a=max(_a,Z);
	_a=max(_a,a0);
	_a=max(_a,b0);
	_a=max(_a,c0);
	_a=max(_a,d0);
	_a=max(_a,e0);
	_a=max(_a,f0);
	_a=max(_a,g0);
	_a=max(_a,h0);
	_a=max(_a,i0);
	_a=max(_a,j0);
	_a=max(_a,k0);
	_a=max(_a,l0);
	printf("%d\n", _a);
}

void solve9() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,a+c);
	d=min(d,a+d);
	e=min(e,a+e);
	f=min(f,a+f);
	g=min(g,a+g);
	h=min(h,a+h);
	i=min(i,a+i);
	j=min(j,j+a);
	k=min(k,j+b);
	l=min(l,j+c);
	m=min(m,j+d);
	n=min(n,j+e);
	o=min(o,j+f);
	p=min(p,j+g);
	q=min(q,j+h);
	r=min(r,j+i);
	s=min(s,s+a);
	t=min(t,s+b);
	u=min(u,s+c);
	v=min(v,s+d);
	w=min(w,s+e);
	x=min(x,s+f);
	y=min(y,s+g);
	z=min(z,s+h);
	A=min(A,s+i);
	B=min(B,B+a);
	C=min(C,B+b);
	D=min(D,B+c);
	E=min(E,B+d);
	F=min(F,B+e);
	G=min(G,B+f);
	H=min(H,B+g);
	I=min(I,B+h);
	J=min(J,B+i);
	K=min(K,K+a);
	L=min(L,K+b);
	M=min(M,K+c);
	N=min(N,K+d);
	O=min(O,K+e);
	P=min(P,K+f);
	Q=min(Q,K+g);
	R=min(R,K+h);
	S=min(S,K+i);
	T=min(T,T+a);
	U=min(U,T+b);
	V=min(V,T+c);
	W=min(W,T+d);
	X=min(X,T+e);
	Y=min(Y,T+f);
	Z=min(Z,T+g);
	a0=min(a0,T+h);
	b0=min(b0,T+i);
	c0=min(c0,c0+a);
	d0=min(d0,c0+b);
	e0=min(e0,c0+c);
	f0=min(f0,c0+d);
	g0=min(g0,c0+e);
	h0=min(h0,c0+f);
	i0=min(i0,c0+g);
	j0=min(j0,c0+h);
	k0=min(k0,c0+i);
	l0=min(l0,l0+a);
	m0=min(m0,l0+b);
	n0=min(n0,l0+c);
	o0=min(o0,l0+d);
	p0=min(p0,l0+e);
	q0=min(q0,l0+f);
	r0=min(r0,l0+g);
	s0=min(s0,l0+h);
	t0=min(t0,l0+i);
	u0=min(u0,u0+a);
	v0=min(v0,u0+b);
	w0=min(w0,u0+c);
	x0=min(x0,u0+d);
	y0=min(y0,u0+e);
	z0=min(z0,u0+f);
	A0=min(A0,u0+g);
	B0=min(B0,u0+h);
	C0=min(C0,u0+i);
	a=min(a,b+j);
	b=min(b,b+k);
	c=min(c,b+l);
	d=min(d,b+m);
	e=min(e,b+n);
	f=min(f,b+o);
	g=min(g,b+p);
	h=min(h,b+q);
	i=min(i,b+r);
	j=min(j,k+j);
	k=min(k,k+k);
	l=min(l,k+l);
	m=min(m,k+m);
	n=min(n,k+n);
	o=min(o,k+o);
	p=min(p,k+p);
	q=min(q,k+q);
	r=min(r,k+r);
	s=min(s,t+j);
	t=min(t,t+k);
	u=min(u,t+l);
	v=min(v,t+m);
	w=min(w,t+n);
	x=min(x,t+o);
	y=min(y,t+p);
	z=min(z,t+q);
	A=min(A,t+r);
	B=min(B,C+j);
	C=min(C,C+k);
	D=min(D,C+l);
	E=min(E,C+m);
	F=min(F,C+n);
	G=min(G,C+o);
	H=min(H,C+p);
	I=min(I,C+q);
	J=min(J,C+r);
	K=min(K,L+j);
	L=min(L,L+k);
	M=min(M,L+l);
	N=min(N,L+m);
	O=min(O,L+n);
	P=min(P,L+o);
	Q=min(Q,L+p);
	R=min(R,L+q);
	S=min(S,L+r);
	T=min(T,U+j);
	U=min(U,U+k);
	V=min(V,U+l);
	W=min(W,U+m);
	X=min(X,U+n);
	Y=min(Y,U+o);
	Z=min(Z,U+p);
	a0=min(a0,U+q);
	b0=min(b0,U+r);
	c0=min(c0,d0+j);
	d0=min(d0,d0+k);
	e0=min(e0,d0+l);
	f0=min(f0,d0+m);
	g0=min(g0,d0+n);
	h0=min(h0,d0+o);
	i0=min(i0,d0+p);
	j0=min(j0,d0+q);
	k0=min(k0,d0+r);
	l0=min(l0,m0+j);
	m0=min(m0,m0+k);
	n0=min(n0,m0+l);
	o0=min(o0,m0+m);
	p0=min(p0,m0+n);
	q0=min(q0,m0+o);
	r0=min(r0,m0+p);
	s0=min(s0,m0+q);
	t0=min(t0,m0+r);
	u0=min(u0,v0+j);
	v0=min(v0,v0+k);
	w0=min(w0,v0+l);
	x0=min(x0,v0+m);
	y0=min(y0,v0+n);
	z0=min(z0,v0+o);
	A0=min(A0,v0+p);
	B0=min(B0,v0+q);
	C0=min(C0,v0+r);
	a=min(a,c+s);
	b=min(b,c+t);
	c=min(c,c+u);
	d=min(d,c+v);
	e=min(e,c+w);
	f=min(f,c+x);
	g=min(g,c+y);
	h=min(h,c+z);
	i=min(i,c+A);
	j=min(j,l+s);
	k=min(k,l+t);
	l=min(l,l+u);
	m=min(m,l+v);
	n=min(n,l+w);
	o=min(o,l+x);
	p=min(p,l+y);
	q=min(q,l+z);
	r=min(r,l+A);
	s=min(s,u+s);
	t=min(t,u+t);
	u=min(u,u+u);
	v=min(v,u+v);
	w=min(w,u+w);
	x=min(x,u+x);
	y=min(y,u+y);
	z=min(z,u+z);
	A=min(A,u+A);
	B=min(B,D+s);
	C=min(C,D+t);
	D=min(D,D+u);
	E=min(E,D+v);
	F=min(F,D+w);
	G=min(G,D+x);
	H=min(H,D+y);
	I=min(I,D+z);
	J=min(J,D+A);
	K=min(K,M+s);
	L=min(L,M+t);
	M=min(M,M+u);
	N=min(N,M+v);
	O=min(O,M+w);
	P=min(P,M+x);
	Q=min(Q,M+y);
	R=min(R,M+z);
	S=min(S,M+A);
	T=min(T,V+s);
	U=min(U,V+t);
	V=min(V,V+u);
	W=min(W,V+v);
	X=min(X,V+w);
	Y=min(Y,V+x);
	Z=min(Z,V+y);
	a0=min(a0,V+z);
	b0=min(b0,V+A);
	c0=min(c0,e0+s);
	d0=min(d0,e0+t);
	e0=min(e0,e0+u);
	f0=min(f0,e0+v);
	g0=min(g0,e0+w);
	h0=min(h0,e0+x);
	i0=min(i0,e0+y);
	j0=min(j0,e0+z);
	k0=min(k0,e0+A);
	l0=min(l0,n0+s);
	m0=min(m0,n0+t);
	n0=min(n0,n0+u);
	o0=min(o0,n0+v);
	p0=min(p0,n0+w);
	q0=min(q0,n0+x);
	r0=min(r0,n0+y);
	s0=min(s0,n0+z);
	t0=min(t0,n0+A);
	u0=min(u0,w0+s);
	v0=min(v0,w0+t);
	w0=min(w0,w0+u);
	x0=min(x0,w0+v);
	y0=min(y0,w0+w);
	z0=min(z0,w0+x);
	A0=min(A0,w0+y);
	B0=min(B0,w0+z);
	C0=min(C0,w0+A);
	a=min(a,d+B);
	b=min(b,d+C);
	c=min(c,d+D);
	d=min(d,d+E);
	e=min(e,d+F);
	f=min(f,d+G);
	g=min(g,d+H);
	h=min(h,d+I);
	i=min(i,d+J);
	j=min(j,m+B);
	k=min(k,m+C);
	l=min(l,m+D);
	m=min(m,m+E);
	n=min(n,m+F);
	o=min(o,m+G);
	p=min(p,m+H);
	q=min(q,m+I);
	r=min(r,m+J);
	s=min(s,v+B);
	t=min(t,v+C);
	u=min(u,v+D);
	v=min(v,v+E);
	w=min(w,v+F);
	x=min(x,v+G);
	y=min(y,v+H);
	z=min(z,v+I);
	A=min(A,v+J);
	B=min(B,E+B);
	C=min(C,E+C);
	D=min(D,E+D);
	E=min(E,E+E);
	F=min(F,E+F);
	G=min(G,E+G);
	H=min(H,E+H);
	I=min(I,E+I);
	J=min(J,E+J);
	K=min(K,N+B);
	L=min(L,N+C);
	M=min(M,N+D);
	N=min(N,N+E);
	O=min(O,N+F);
	P=min(P,N+G);
	Q=min(Q,N+H);
	R=min(R,N+I);
	S=min(S,N+J);
	T=min(T,W+B);
	U=min(U,W+C);
	V=min(V,W+D);
	W=min(W,W+E);
	X=min(X,W+F);
	Y=min(Y,W+G);
	Z=min(Z,W+H);
	a0=min(a0,W+I);
	b0=min(b0,W+J);
	c0=min(c0,f0+B);
	d0=min(d0,f0+C);
	e0=min(e0,f0+D);
	f0=min(f0,f0+E);
	g0=min(g0,f0+F);
	h0=min(h0,f0+G);
	i0=min(i0,f0+H);
	j0=min(j0,f0+I);
	k0=min(k0,f0+J);
	l0=min(l0,o0+B);
	m0=min(m0,o0+C);
	n0=min(n0,o0+D);
	o0=min(o0,o0+E);
	p0=min(p0,o0+F);
	q0=min(q0,o0+G);
	r0=min(r0,o0+H);
	s0=min(s0,o0+I);
	t0=min(t0,o0+J);
	u0=min(u0,x0+B);
	v0=min(v0,x0+C);
	w0=min(w0,x0+D);
	x0=min(x0,x0+E);
	y0=min(y0,x0+F);
	z0=min(z0,x0+G);
	A0=min(A0,x0+H);
	B0=min(B0,x0+I);
	C0=min(C0,x0+J);
	a=min(a,e+K);
	b=min(b,e+L);
	c=min(c,e+M);
	d=min(d,e+N);
	e=min(e,e+O);
	f=min(f,e+P);
	g=min(g,e+Q);
	h=min(h,e+R);
	i=min(i,e+S);
	j=min(j,n+K);
	k=min(k,n+L);
	l=min(l,n+M);
	m=min(m,n+N);
	n=min(n,n+O);
	o=min(o,n+P);
	p=min(p,n+Q);
	q=min(q,n+R);
	r=min(r,n+S);
	s=min(s,w+K);
	t=min(t,w+L);
	u=min(u,w+M);
	v=min(v,w+N);
	w=min(w,w+O);
	x=min(x,w+P);
	y=min(y,w+Q);
	z=min(z,w+R);
	A=min(A,w+S);
	B=min(B,F+K);
	C=min(C,F+L);
	D=min(D,F+M);
	E=min(E,F+N);
	F=min(F,F+O);
	G=min(G,F+P);
	H=min(H,F+Q);
	I=min(I,F+R);
	J=min(J,F+S);
	K=min(K,O+K);
	L=min(L,O+L);
	M=min(M,O+M);
	N=min(N,O+N);
	O=min(O,O+O);
	P=min(P,O+P);
	Q=min(Q,O+Q);
	R=min(R,O+R);
	S=min(S,O+S);
	T=min(T,X+K);
	U=min(U,X+L);
	V=min(V,X+M);
	W=min(W,X+N);
	X=min(X,X+O);
	Y=min(Y,X+P);
	Z=min(Z,X+Q);
	a0=min(a0,X+R);
	b0=min(b0,X+S);
	c0=min(c0,g0+K);
	d0=min(d0,g0+L);
	e0=min(e0,g0+M);
	f0=min(f0,g0+N);
	g0=min(g0,g0+O);
	h0=min(h0,g0+P);
	i0=min(i0,g0+Q);
	j0=min(j0,g0+R);
	k0=min(k0,g0+S);
	l0=min(l0,p0+K);
	m0=min(m0,p0+L);
	n0=min(n0,p0+M);
	o0=min(o0,p0+N);
	p0=min(p0,p0+O);
	q0=min(q0,p0+P);
	r0=min(r0,p0+Q);
	s0=min(s0,p0+R);
	t0=min(t0,p0+S);
	u0=min(u0,y0+K);
	v0=min(v0,y0+L);
	w0=min(w0,y0+M);
	x0=min(x0,y0+N);
	y0=min(y0,y0+O);
	z0=min(z0,y0+P);
	A0=min(A0,y0+Q);
	B0=min(B0,y0+R);
	C0=min(C0,y0+S);
	a=min(a,f+T);
	b=min(b,f+U);
	c=min(c,f+V);
	d=min(d,f+W);
	e=min(e,f+X);
	f=min(f,f+Y);
	g=min(g,f+Z);
	h=min(h,f+a0);
	i=min(i,f+b0);
	j=min(j,o+T);
	k=min(k,o+U);
	l=min(l,o+V);
	m=min(m,o+W);
	n=min(n,o+X);
	o=min(o,o+Y);
	p=min(p,o+Z);
	q=min(q,o+a0);
	r=min(r,o+b0);
	s=min(s,x+T);
	t=min(t,x+U);
	u=min(u,x+V);
	v=min(v,x+W);
	w=min(w,x+X);
	x=min(x,x+Y);
	y=min(y,x+Z);
	z=min(z,x+a0);
	A=min(A,x+b0);
	B=min(B,G+T);
	C=min(C,G+U);
	D=min(D,G+V);
	E=min(E,G+W);
	F=min(F,G+X);
	G=min(G,G+Y);
	H=min(H,G+Z);
	I=min(I,G+a0);
	J=min(J,G+b0);
	K=min(K,P+T);
	L=min(L,P+U);
	M=min(M,P+V);
	N=min(N,P+W);
	O=min(O,P+X);
	P=min(P,P+Y);
	Q=min(Q,P+Z);
	R=min(R,P+a0);
	S=min(S,P+b0);
	T=min(T,Y+T);
	U=min(U,Y+U);
	V=min(V,Y+V);
	W=min(W,Y+W);
	X=min(X,Y+X);
	Y=min(Y,Y+Y);
	Z=min(Z,Y+Z);
	a0=min(a0,Y+a0);
	b0=min(b0,Y+b0);
	c0=min(c0,h0+T);
	d0=min(d0,h0+U);
	e0=min(e0,h0+V);
	f0=min(f0,h0+W);
	g0=min(g0,h0+X);
	h0=min(h0,h0+Y);
	i0=min(i0,h0+Z);
	j0=min(j0,h0+a0);
	k0=min(k0,h0+b0);
	l0=min(l0,q0+T);
	m0=min(m0,q0+U);
	n0=min(n0,q0+V);
	o0=min(o0,q0+W);
	p0=min(p0,q0+X);
	q0=min(q0,q0+Y);
	r0=min(r0,q0+Z);
	s0=min(s0,q0+a0);
	t0=min(t0,q0+b0);
	u0=min(u0,z0+T);
	v0=min(v0,z0+U);
	w0=min(w0,z0+V);
	x0=min(x0,z0+W);
	y0=min(y0,z0+X);
	z0=min(z0,z0+Y);
	A0=min(A0,z0+Z);
	B0=min(B0,z0+a0);
	C0=min(C0,z0+b0);
	a=min(a,g+c0);
	b=min(b,g+d0);
	c=min(c,g+e0);
	d=min(d,g+f0);
	e=min(e,g+g0);
	f=min(f,g+h0);
	g=min(g,g+i0);
	h=min(h,g+j0);
	i=min(i,g+k0);
	j=min(j,p+c0);
	k=min(k,p+d0);
	l=min(l,p+e0);
	m=min(m,p+f0);
	n=min(n,p+g0);
	o=min(o,p+h0);
	p=min(p,p+i0);
	q=min(q,p+j0);
	r=min(r,p+k0);
	s=min(s,y+c0);
	t=min(t,y+d0);
	u=min(u,y+e0);
	v=min(v,y+f0);
	w=min(w,y+g0);
	x=min(x,y+h0);
	y=min(y,y+i0);
	z=min(z,y+j0);
	A=min(A,y+k0);
	B=min(B,H+c0);
	C=min(C,H+d0);
	D=min(D,H+e0);
	E=min(E,H+f0);
	F=min(F,H+g0);
	G=min(G,H+h0);
	H=min(H,H+i0);
	I=min(I,H+j0);
	J=min(J,H+k0);
	K=min(K,Q+c0);
	L=min(L,Q+d0);
	M=min(M,Q+e0);
	N=min(N,Q+f0);
	O=min(O,Q+g0);
	P=min(P,Q+h0);
	Q=min(Q,Q+i0);
	R=min(R,Q+j0);
	S=min(S,Q+k0);
	T=min(T,Z+c0);
	U=min(U,Z+d0);
	V=min(V,Z+e0);
	W=min(W,Z+f0);
	X=min(X,Z+g0);
	Y=min(Y,Z+h0);
	Z=min(Z,Z+i0);
	a0=min(a0,Z+j0);
	b0=min(b0,Z+k0);
	c0=min(c0,i0+c0);
	d0=min(d0,i0+d0);
	e0=min(e0,i0+e0);
	f0=min(f0,i0+f0);
	g0=min(g0,i0+g0);
	h0=min(h0,i0+h0);
	i0=min(i0,i0+i0);
	j0=min(j0,i0+j0);
	k0=min(k0,i0+k0);
	l0=min(l0,r0+c0);
	m0=min(m0,r0+d0);
	n0=min(n0,r0+e0);
	o0=min(o0,r0+f0);
	p0=min(p0,r0+g0);
	q0=min(q0,r0+h0);
	r0=min(r0,r0+i0);
	s0=min(s0,r0+j0);
	t0=min(t0,r0+k0);
	u0=min(u0,A0+c0);
	v0=min(v0,A0+d0);
	w0=min(w0,A0+e0);
	x0=min(x0,A0+f0);
	y0=min(y0,A0+g0);
	z0=min(z0,A0+h0);
	A0=min(A0,A0+i0);
	B0=min(B0,A0+j0);
	C0=min(C0,A0+k0);
	a=min(a,h+l0);
	b=min(b,h+m0);
	c=min(c,h+n0);
	d=min(d,h+o0);
	e=min(e,h+p0);
	f=min(f,h+q0);
	g=min(g,h+r0);
	h=min(h,h+s0);
	i=min(i,h+t0);
	j=min(j,q+l0);
	k=min(k,q+m0);
	l=min(l,q+n0);
	m=min(m,q+o0);
	n=min(n,q+p0);
	o=min(o,q+q0);
	p=min(p,q+r0);
	q=min(q,q+s0);
	r=min(r,q+t0);
	s=min(s,z+l0);
	t=min(t,z+m0);
	u=min(u,z+n0);
	v=min(v,z+o0);
	w=min(w,z+p0);
	x=min(x,z+q0);
	y=min(y,z+r0);
	z=min(z,z+s0);
	A=min(A,z+t0);
	B=min(B,I+l0);
	C=min(C,I+m0);
	D=min(D,I+n0);
	E=min(E,I+o0);
	F=min(F,I+p0);
	G=min(G,I+q0);
	H=min(H,I+r0);
	I=min(I,I+s0);
	J=min(J,I+t0);
	K=min(K,R+l0);
	L=min(L,R+m0);
	M=min(M,R+n0);
	N=min(N,R+o0);
	O=min(O,R+p0);
	P=min(P,R+q0);
	Q=min(Q,R+r0);
	R=min(R,R+s0);
	S=min(S,R+t0);
	T=min(T,a0+l0);
	U=min(U,a0+m0);
	V=min(V,a0+n0);
	W=min(W,a0+o0);
	X=min(X,a0+p0);
	Y=min(Y,a0+q0);
	Z=min(Z,a0+r0);
	a0=min(a0,a0+s0);
	b0=min(b0,a0+t0);
	c0=min(c0,j0+l0);
	d0=min(d0,j0+m0);
	e0=min(e0,j0+n0);
	f0=min(f0,j0+o0);
	g0=min(g0,j0+p0);
	h0=min(h0,j0+q0);
	i0=min(i0,j0+r0);
	j0=min(j0,j0+s0);
	k0=min(k0,j0+t0);
	l0=min(l0,s0+l0);
	m0=min(m0,s0+m0);
	n0=min(n0,s0+n0);
	o0=min(o0,s0+o0);
	p0=min(p0,s0+p0);
	q0=min(q0,s0+q0);
	r0=min(r0,s0+r0);
	s0=min(s0,s0+s0);
	t0=min(t0,s0+t0);
	u0=min(u0,B0+l0);
	v0=min(v0,B0+m0);
	w0=min(w0,B0+n0);
	x0=min(x0,B0+o0);
	y0=min(y0,B0+p0);
	z0=min(z0,B0+q0);
	A0=min(A0,B0+r0);
	B0=min(B0,B0+s0);
	C0=min(C0,B0+t0);
	a=min(a,i+u0);
	b=min(b,i+v0);
	c=min(c,i+w0);
	d=min(d,i+x0);
	e=min(e,i+y0);
	f=min(f,i+z0);
	g=min(g,i+A0);
	h=min(h,i+B0);
	i=min(i,i+C0);
	j=min(j,r+u0);
	k=min(k,r+v0);
	l=min(l,r+w0);
	m=min(m,r+x0);
	n=min(n,r+y0);
	o=min(o,r+z0);
	p=min(p,r+A0);
	q=min(q,r+B0);
	r=min(r,r+C0);
	s=min(s,A+u0);
	t=min(t,A+v0);
	u=min(u,A+w0);
	v=min(v,A+x0);
	w=min(w,A+y0);
	x=min(x,A+z0);
	y=min(y,A+A0);
	z=min(z,A+B0);
	A=min(A,A+C0);
	B=min(B,J+u0);
	C=min(C,J+v0);
	D=min(D,J+w0);
	E=min(E,J+x0);
	F=min(F,J+y0);
	G=min(G,J+z0);
	H=min(H,J+A0);
	I=min(I,J+B0);
	J=min(J,J+C0);
	K=min(K,S+u0);
	L=min(L,S+v0);
	M=min(M,S+w0);
	N=min(N,S+x0);
	O=min(O,S+y0);
	P=min(P,S+z0);
	Q=min(Q,S+A0);
	R=min(R,S+B0);
	S=min(S,S+C0);
	T=min(T,b0+u0);
	U=min(U,b0+v0);
	V=min(V,b0+w0);
	W=min(W,b0+x0);
	X=min(X,b0+y0);
	Y=min(Y,b0+z0);
	Z=min(Z,b0+A0);
	a0=min(a0,b0+B0);
	b0=min(b0,b0+C0);
	c0=min(c0,k0+u0);
	d0=min(d0,k0+v0);
	e0=min(e0,k0+w0);
	f0=min(f0,k0+x0);
	g0=min(g0,k0+y0);
	h0=min(h0,k0+z0);
	i0=min(i0,k0+A0);
	j0=min(j0,k0+B0);
	k0=min(k0,k0+C0);
	l0=min(l0,t0+u0);
	m0=min(m0,t0+v0);
	n0=min(n0,t0+w0);
	o0=min(o0,t0+x0);
	p0=min(p0,t0+y0);
	q0=min(q0,t0+z0);
	r0=min(r0,t0+A0);
	s0=min(s0,t0+B0);
	t0=min(t0,t0+C0);
	u0=min(u0,C0+u0);
	v0=min(v0,C0+v0);
	w0=min(w0,C0+w0);
	x0=min(x0,C0+x0);
	y0=min(y0,C0+y0);
	z0=min(z0,C0+z0);
	A0=min(A0,C0+A0);
	B0=min(B0,C0+B0);
	C0=min(C0,C0+C0);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	_a=max(_a,e);
	_a=max(_a,f);
	_a=max(_a,g);
	_a=max(_a,h);
	_a=max(_a,i);
	_a=max(_a,j);
	_a=max(_a,k);
	_a=max(_a,l);
	_a=max(_a,m);
	_a=max(_a,n);
	_a=max(_a,o);
	_a=max(_a,p);
	_a=max(_a,q);
	_a=max(_a,r);
	_a=max(_a,s);
	_a=max(_a,t);
	_a=max(_a,u);
	_a=max(_a,v);
	_a=max(_a,w);
	_a=max(_a,x);
	_a=max(_a,y);
	_a=max(_a,z);
	_a=max(_a,A);
	_a=max(_a,B);
	_a=max(_a,C);
	_a=max(_a,D);
	_a=max(_a,E);
	_a=max(_a,F);
	_a=max(_a,G);
	_a=max(_a,H);
	_a=max(_a,I);
	_a=max(_a,J);
	_a=max(_a,K);
	_a=max(_a,L);
	_a=max(_a,M);
	_a=max(_a,N);
	_a=max(_a,O);
	_a=max(_a,P);
	_a=max(_a,Q);
	_a=max(_a,R);
	_a=max(_a,S);
	_a=max(_a,T);
	_a=max(_a,U);
	_a=max(_a,V);
	_a=max(_a,W);
	_a=max(_a,X);
	_a=max(_a,Y);
	_a=max(_a,Z);
	_a=max(_a,a0);
	_a=max(_a,b0);
	_a=max(_a,c0);
	_a=max(_a,d0);
	_a=max(_a,e0);
	_a=max(_a,f0);
	_a=max(_a,g0);
	_a=max(_a,h0);
	_a=max(_a,i0);
	_a=max(_a,j0);
	_a=max(_a,k0);
	_a=max(_a,l0);
	_a=max(_a,m0);
	_a=max(_a,n0);
	_a=max(_a,o0);
	_a=max(_a,p0);
	_a=max(_a,q0);
	_a=max(_a,r0);
	_a=max(_a,s0);
	_a=max(_a,t0);
	_a=max(_a,u0);
	_a=max(_a,v0);
	_a=max(_a,w0);
	_a=max(_a,x0);
	_a=max(_a,y0);
	_a=max(_a,z0);
	_a=max(_a,A0);
	_a=max(_a,B0);
	_a=max(_a,C0);
	printf("%d\n", _a);
}

void solve10() {
	a=min(a,a+a);
	b=min(b,a+b);
	c=min(c,a+c);
	d=min(d,a+d);
	e=min(e,a+e);
	f=min(f,a+f);
	g=min(g,a+g);
	h=min(h,a+h);
	i=min(i,a+i);
	j=min(j,a+j);
	k=min(k,k+a);
	l=min(l,k+b);
	m=min(m,k+c);
	n=min(n,k+d);
	o=min(o,k+e);
	p=min(p,k+f);
	q=min(q,k+g);
	r=min(r,k+h);
	s=min(s,k+i);
	t=min(t,k+j);
	u=min(u,u+a);
	v=min(v,u+b);
	w=min(w,u+c);
	x=min(x,u+d);
	y=min(y,u+e);
	z=min(z,u+f);
	A=min(A,u+g);
	B=min(B,u+h);
	C=min(C,u+i);
	D=min(D,u+j);
	E=min(E,E+a);
	F=min(F,E+b);
	G=min(G,E+c);
	H=min(H,E+d);
	I=min(I,E+e);
	J=min(J,E+f);
	K=min(K,E+g);
	L=min(L,E+h);
	M=min(M,E+i);
	N=min(N,E+j);
	O=min(O,O+a);
	P=min(P,O+b);
	Q=min(Q,O+c);
	R=min(R,O+d);
	S=min(S,O+e);
	T=min(T,O+f);
	U=min(U,O+g);
	V=min(V,O+h);
	W=min(W,O+i);
	X=min(X,O+j);
	Y=min(Y,Y+a);
	Z=min(Z,Y+b);
	a0=min(a0,Y+c);
	b0=min(b0,Y+d);
	c0=min(c0,Y+e);
	d0=min(d0,Y+f);
	e0=min(e0,Y+g);
	f0=min(f0,Y+h);
	g0=min(g0,Y+i);
	h0=min(h0,Y+j);
	i0=min(i0,i0+a);
	j0=min(j0,i0+b);
	k0=min(k0,i0+c);
	l0=min(l0,i0+d);
	m0=min(m0,i0+e);
	n0=min(n0,i0+f);
	o0=min(o0,i0+g);
	p0=min(p0,i0+h);
	q0=min(q0,i0+i);
	r0=min(r0,i0+j);
	s0=min(s0,s0+a);
	t0=min(t0,s0+b);
	u0=min(u0,s0+c);
	v0=min(v0,s0+d);
	w0=min(w0,s0+e);
	x0=min(x0,s0+f);
	y0=min(y0,s0+g);
	z0=min(z0,s0+h);
	A0=min(A0,s0+i);
	B0=min(B0,s0+j);
	C0=min(C0,C0+a);
	D0=min(D0,C0+b);
	E0=min(E0,C0+c);
	F0=min(F0,C0+d);
	G0=min(G0,C0+e);
	H0=min(H0,C0+f);
	I0=min(I0,C0+g);
	J0=min(J0,C0+h);
	K0=min(K0,C0+i);
	L0=min(L0,C0+j);
	M0=min(M0,M0+a);
	N0=min(N0,M0+b);
	O0=min(O0,M0+c);
	P0=min(P0,M0+d);
	Q0=min(Q0,M0+e);
	R0=min(R0,M0+f);
	S0=min(S0,M0+g);
	T0=min(T0,M0+h);
	U0=min(U0,M0+i);
	V0=min(V0,M0+j);
	a=min(a,b+k);
	b=min(b,b+l);
	c=min(c,b+m);
	d=min(d,b+n);
	e=min(e,b+o);
	f=min(f,b+p);
	g=min(g,b+q);
	h=min(h,b+r);
	i=min(i,b+s);
	j=min(j,b+t);
	k=min(k,l+k);
	l=min(l,l+l);
	m=min(m,l+m);
	n=min(n,l+n);
	o=min(o,l+o);
	p=min(p,l+p);
	q=min(q,l+q);
	r=min(r,l+r);
	s=min(s,l+s);
	t=min(t,l+t);
	u=min(u,v+k);
	v=min(v,v+l);
	w=min(w,v+m);
	x=min(x,v+n);
	y=min(y,v+o);
	z=min(z,v+p);
	A=min(A,v+q);
	B=min(B,v+r);
	C=min(C,v+s);
	D=min(D,v+t);
	E=min(E,F+k);
	F=min(F,F+l);
	G=min(G,F+m);
	H=min(H,F+n);
	I=min(I,F+o);
	J=min(J,F+p);
	K=min(K,F+q);
	L=min(L,F+r);
	M=min(M,F+s);
	N=min(N,F+t);
	O=min(O,P+k);
	P=min(P,P+l);
	Q=min(Q,P+m);
	R=min(R,P+n);
	S=min(S,P+o);
	T=min(T,P+p);
	U=min(U,P+q);
	V=min(V,P+r);
	W=min(W,P+s);
	X=min(X,P+t);
	Y=min(Y,Z+k);
	Z=min(Z,Z+l);
	a0=min(a0,Z+m);
	b0=min(b0,Z+n);
	c0=min(c0,Z+o);
	d0=min(d0,Z+p);
	e0=min(e0,Z+q);
	f0=min(f0,Z+r);
	g0=min(g0,Z+s);
	h0=min(h0,Z+t);
	i0=min(i0,j0+k);
	j0=min(j0,j0+l);
	k0=min(k0,j0+m);
	l0=min(l0,j0+n);
	m0=min(m0,j0+o);
	n0=min(n0,j0+p);
	o0=min(o0,j0+q);
	p0=min(p0,j0+r);
	q0=min(q0,j0+s);
	r0=min(r0,j0+t);
	s0=min(s0,t0+k);
	t0=min(t0,t0+l);
	u0=min(u0,t0+m);
	v0=min(v0,t0+n);
	w0=min(w0,t0+o);
	x0=min(x0,t0+p);
	y0=min(y0,t0+q);
	z0=min(z0,t0+r);
	A0=min(A0,t0+s);
	B0=min(B0,t0+t);
	C0=min(C0,D0+k);
	D0=min(D0,D0+l);
	E0=min(E0,D0+m);
	F0=min(F0,D0+n);
	G0=min(G0,D0+o);
	H0=min(H0,D0+p);
	I0=min(I0,D0+q);
	J0=min(J0,D0+r);
	K0=min(K0,D0+s);
	L0=min(L0,D0+t);
	M0=min(M0,N0+k);
	N0=min(N0,N0+l);
	O0=min(O0,N0+m);
	P0=min(P0,N0+n);
	Q0=min(Q0,N0+o);
	R0=min(R0,N0+p);
	S0=min(S0,N0+q);
	T0=min(T0,N0+r);
	U0=min(U0,N0+s);
	V0=min(V0,N0+t);
	a=min(a,c+u);
	b=min(b,c+v);
	c=min(c,c+w);
	d=min(d,c+x);
	e=min(e,c+y);
	f=min(f,c+z);
	g=min(g,c+A);
	h=min(h,c+B);
	i=min(i,c+C);
	j=min(j,c+D);
	k=min(k,m+u);
	l=min(l,m+v);
	m=min(m,m+w);
	n=min(n,m+x);
	o=min(o,m+y);
	p=min(p,m+z);
	q=min(q,m+A);
	r=min(r,m+B);
	s=min(s,m+C);
	t=min(t,m+D);
	u=min(u,w+u);
	v=min(v,w+v);
	w=min(w,w+w);
	x=min(x,w+x);
	y=min(y,w+y);
	z=min(z,w+z);
	A=min(A,w+A);
	B=min(B,w+B);
	C=min(C,w+C);
	D=min(D,w+D);
	E=min(E,G+u);
	F=min(F,G+v);
	G=min(G,G+w);
	H=min(H,G+x);
	I=min(I,G+y);
	J=min(J,G+z);
	K=min(K,G+A);
	L=min(L,G+B);
	M=min(M,G+C);
	N=min(N,G+D);
	O=min(O,Q+u);
	P=min(P,Q+v);
	Q=min(Q,Q+w);
	R=min(R,Q+x);
	S=min(S,Q+y);
	T=min(T,Q+z);
	U=min(U,Q+A);
	V=min(V,Q+B);
	W=min(W,Q+C);
	X=min(X,Q+D);
	Y=min(Y,a0+u);
	Z=min(Z,a0+v);
	a0=min(a0,a0+w);
	b0=min(b0,a0+x);
	c0=min(c0,a0+y);
	d0=min(d0,a0+z);
	e0=min(e0,a0+A);
	f0=min(f0,a0+B);
	g0=min(g0,a0+C);
	h0=min(h0,a0+D);
	i0=min(i0,k0+u);
	j0=min(j0,k0+v);
	k0=min(k0,k0+w);
	l0=min(l0,k0+x);
	m0=min(m0,k0+y);
	n0=min(n0,k0+z);
	o0=min(o0,k0+A);
	p0=min(p0,k0+B);
	q0=min(q0,k0+C);
	r0=min(r0,k0+D);
	s0=min(s0,u0+u);
	t0=min(t0,u0+v);
	u0=min(u0,u0+w);
	v0=min(v0,u0+x);
	w0=min(w0,u0+y);
	x0=min(x0,u0+z);
	y0=min(y0,u0+A);
	z0=min(z0,u0+B);
	A0=min(A0,u0+C);
	B0=min(B0,u0+D);
	C0=min(C0,E0+u);
	D0=min(D0,E0+v);
	E0=min(E0,E0+w);
	F0=min(F0,E0+x);
	G0=min(G0,E0+y);
	H0=min(H0,E0+z);
	I0=min(I0,E0+A);
	J0=min(J0,E0+B);
	K0=min(K0,E0+C);
	L0=min(L0,E0+D);
	M0=min(M0,O0+u);
	N0=min(N0,O0+v);
	O0=min(O0,O0+w);
	P0=min(P0,O0+x);
	Q0=min(Q0,O0+y);
	R0=min(R0,O0+z);
	S0=min(S0,O0+A);
	T0=min(T0,O0+B);
	U0=min(U0,O0+C);
	V0=min(V0,O0+D);
	a=min(a,d+E);
	b=min(b,d+F);
	c=min(c,d+G);
	d=min(d,d+H);
	e=min(e,d+I);
	f=min(f,d+J);
	g=min(g,d+K);
	h=min(h,d+L);
	i=min(i,d+M);
	j=min(j,d+N);
	k=min(k,n+E);
	l=min(l,n+F);
	m=min(m,n+G);
	n=min(n,n+H);
	o=min(o,n+I);
	p=min(p,n+J);
	q=min(q,n+K);
	r=min(r,n+L);
	s=min(s,n+M);
	t=min(t,n+N);
	u=min(u,x+E);
	v=min(v,x+F);
	w=min(w,x+G);
	x=min(x,x+H);
	y=min(y,x+I);
	z=min(z,x+J);
	A=min(A,x+K);
	B=min(B,x+L);
	C=min(C,x+M);
	D=min(D,x+N);
	E=min(E,H+E);
	F=min(F,H+F);
	G=min(G,H+G);
	H=min(H,H+H);
	I=min(I,H+I);
	J=min(J,H+J);
	K=min(K,H+K);
	L=min(L,H+L);
	M=min(M,H+M);
	N=min(N,H+N);
	O=min(O,R+E);
	P=min(P,R+F);
	Q=min(Q,R+G);
	R=min(R,R+H);
	S=min(S,R+I);
	T=min(T,R+J);
	U=min(U,R+K);
	V=min(V,R+L);
	W=min(W,R+M);
	X=min(X,R+N);
	Y=min(Y,b0+E);
	Z=min(Z,b0+F);
	a0=min(a0,b0+G);
	b0=min(b0,b0+H);
	c0=min(c0,b0+I);
	d0=min(d0,b0+J);
	e0=min(e0,b0+K);
	f0=min(f0,b0+L);
	g0=min(g0,b0+M);
	h0=min(h0,b0+N);
	i0=min(i0,l0+E);
	j0=min(j0,l0+F);
	k0=min(k0,l0+G);
	l0=min(l0,l0+H);
	m0=min(m0,l0+I);
	n0=min(n0,l0+J);
	o0=min(o0,l0+K);
	p0=min(p0,l0+L);
	q0=min(q0,l0+M);
	r0=min(r0,l0+N);
	s0=min(s0,v0+E);
	t0=min(t0,v0+F);
	u0=min(u0,v0+G);
	v0=min(v0,v0+H);
	w0=min(w0,v0+I);
	x0=min(x0,v0+J);
	y0=min(y0,v0+K);
	z0=min(z0,v0+L);
	A0=min(A0,v0+M);
	B0=min(B0,v0+N);
	C0=min(C0,F0+E);
	D0=min(D0,F0+F);
	E0=min(E0,F0+G);
	F0=min(F0,F0+H);
	G0=min(G0,F0+I);
	H0=min(H0,F0+J);
	I0=min(I0,F0+K);
	J0=min(J0,F0+L);
	K0=min(K0,F0+M);
	L0=min(L0,F0+N);
	M0=min(M0,P0+E);
	N0=min(N0,P0+F);
	O0=min(O0,P0+G);
	P0=min(P0,P0+H);
	Q0=min(Q0,P0+I);
	R0=min(R0,P0+J);
	S0=min(S0,P0+K);
	T0=min(T0,P0+L);
	U0=min(U0,P0+M);
	V0=min(V0,P0+N);
	a=min(a,e+O);
	b=min(b,e+P);
	c=min(c,e+Q);
	d=min(d,e+R);
	e=min(e,e+S);
	f=min(f,e+T);
	g=min(g,e+U);
	h=min(h,e+V);
	i=min(i,e+W);
	j=min(j,e+X);
	k=min(k,o+O);
	l=min(l,o+P);
	m=min(m,o+Q);
	n=min(n,o+R);
	o=min(o,o+S);
	p=min(p,o+T);
	q=min(q,o+U);
	r=min(r,o+V);
	s=min(s,o+W);
	t=min(t,o+X);
	u=min(u,y+O);
	v=min(v,y+P);
	w=min(w,y+Q);
	x=min(x,y+R);
	y=min(y,y+S);
	z=min(z,y+T);
	A=min(A,y+U);
	B=min(B,y+V);
	C=min(C,y+W);
	D=min(D,y+X);
	E=min(E,I+O);
	F=min(F,I+P);
	G=min(G,I+Q);
	H=min(H,I+R);
	I=min(I,I+S);
	J=min(J,I+T);
	K=min(K,I+U);
	L=min(L,I+V);
	M=min(M,I+W);
	N=min(N,I+X);
	O=min(O,S+O);
	P=min(P,S+P);
	Q=min(Q,S+Q);
	R=min(R,S+R);
	S=min(S,S+S);
	T=min(T,S+T);
	U=min(U,S+U);
	V=min(V,S+V);
	W=min(W,S+W);
	X=min(X,S+X);
	Y=min(Y,c0+O);
	Z=min(Z,c0+P);
	a0=min(a0,c0+Q);
	b0=min(b0,c0+R);
	c0=min(c0,c0+S);
	d0=min(d0,c0+T);
	e0=min(e0,c0+U);
	f0=min(f0,c0+V);
	g0=min(g0,c0+W);
	h0=min(h0,c0+X);
	i0=min(i0,m0+O);
	j0=min(j0,m0+P);
	k0=min(k0,m0+Q);
	l0=min(l0,m0+R);
	m0=min(m0,m0+S);
	n0=min(n0,m0+T);
	o0=min(o0,m0+U);
	p0=min(p0,m0+V);
	q0=min(q0,m0+W);
	r0=min(r0,m0+X);
	s0=min(s0,w0+O);
	t0=min(t0,w0+P);
	u0=min(u0,w0+Q);
	v0=min(v0,w0+R);
	w0=min(w0,w0+S);
	x0=min(x0,w0+T);
	y0=min(y0,w0+U);
	z0=min(z0,w0+V);
	A0=min(A0,w0+W);
	B0=min(B0,w0+X);
	C0=min(C0,G0+O);
	D0=min(D0,G0+P);
	E0=min(E0,G0+Q);
	F0=min(F0,G0+R);
	G0=min(G0,G0+S);
	H0=min(H0,G0+T);
	I0=min(I0,G0+U);
	J0=min(J0,G0+V);
	K0=min(K0,G0+W);
	L0=min(L0,G0+X);
	M0=min(M0,Q0+O);
	N0=min(N0,Q0+P);
	O0=min(O0,Q0+Q);
	P0=min(P0,Q0+R);
	Q0=min(Q0,Q0+S);
	R0=min(R0,Q0+T);
	S0=min(S0,Q0+U);
	T0=min(T0,Q0+V);
	U0=min(U0,Q0+W);
	V0=min(V0,Q0+X);
	a=min(a,f+Y);
	b=min(b,f+Z);
	c=min(c,f+a0);
	d=min(d,f+b0);
	e=min(e,f+c0);
	f=min(f,f+d0);
	g=min(g,f+e0);
	h=min(h,f+f0);
	i=min(i,f+g0);
	j=min(j,f+h0);
	k=min(k,p+Y);
	l=min(l,p+Z);
	m=min(m,p+a0);
	n=min(n,p+b0);
	o=min(o,p+c0);
	p=min(p,p+d0);
	q=min(q,p+e0);
	r=min(r,p+f0);
	s=min(s,p+g0);
	t=min(t,p+h0);
	u=min(u,z+Y);
	v=min(v,z+Z);
	w=min(w,z+a0);
	x=min(x,z+b0);
	y=min(y,z+c0);
	z=min(z,z+d0);
	A=min(A,z+e0);
	B=min(B,z+f0);
	C=min(C,z+g0);
	D=min(D,z+h0);
	E=min(E,J+Y);
	F=min(F,J+Z);
	G=min(G,J+a0);
	H=min(H,J+b0);
	I=min(I,J+c0);
	J=min(J,J+d0);
	K=min(K,J+e0);
	L=min(L,J+f0);
	M=min(M,J+g0);
	N=min(N,J+h0);
	O=min(O,T+Y);
	P=min(P,T+Z);
	Q=min(Q,T+a0);
	R=min(R,T+b0);
	S=min(S,T+c0);
	T=min(T,T+d0);
	U=min(U,T+e0);
	V=min(V,T+f0);
	W=min(W,T+g0);
	X=min(X,T+h0);
	Y=min(Y,d0+Y);
	Z=min(Z,d0+Z);
	a0=min(a0,d0+a0);
	b0=min(b0,d0+b0);
	c0=min(c0,d0+c0);
	d0=min(d0,d0+d0);
	e0=min(e0,d0+e0);
	f0=min(f0,d0+f0);
	g0=min(g0,d0+g0);
	h0=min(h0,d0+h0);
	i0=min(i0,n0+Y);
	j0=min(j0,n0+Z);
	k0=min(k0,n0+a0);
	l0=min(l0,n0+b0);
	m0=min(m0,n0+c0);
	n0=min(n0,n0+d0);
	o0=min(o0,n0+e0);
	p0=min(p0,n0+f0);
	q0=min(q0,n0+g0);
	r0=min(r0,n0+h0);
	s0=min(s0,x0+Y);
	t0=min(t0,x0+Z);
	u0=min(u0,x0+a0);
	v0=min(v0,x0+b0);
	w0=min(w0,x0+c0);
	x0=min(x0,x0+d0);
	y0=min(y0,x0+e0);
	z0=min(z0,x0+f0);
	A0=min(A0,x0+g0);
	B0=min(B0,x0+h0);
	C0=min(C0,H0+Y);
	D0=min(D0,H0+Z);
	E0=min(E0,H0+a0);
	F0=min(F0,H0+b0);
	G0=min(G0,H0+c0);
	H0=min(H0,H0+d0);
	I0=min(I0,H0+e0);
	J0=min(J0,H0+f0);
	K0=min(K0,H0+g0);
	L0=min(L0,H0+h0);
	M0=min(M0,R0+Y);
	N0=min(N0,R0+Z);
	O0=min(O0,R0+a0);
	P0=min(P0,R0+b0);
	Q0=min(Q0,R0+c0);
	R0=min(R0,R0+d0);
	S0=min(S0,R0+e0);
	T0=min(T0,R0+f0);
	U0=min(U0,R0+g0);
	V0=min(V0,R0+h0);
	a=min(a,g+i0);
	b=min(b,g+j0);
	c=min(c,g+k0);
	d=min(d,g+l0);
	e=min(e,g+m0);
	f=min(f,g+n0);
	g=min(g,g+o0);
	h=min(h,g+p0);
	i=min(i,g+q0);
	j=min(j,g+r0);
	k=min(k,q+i0);
	l=min(l,q+j0);
	m=min(m,q+k0);
	n=min(n,q+l0);
	o=min(o,q+m0);
	p=min(p,q+n0);
	q=min(q,q+o0);
	r=min(r,q+p0);
	s=min(s,q+q0);
	t=min(t,q+r0);
	u=min(u,A+i0);
	v=min(v,A+j0);
	w=min(w,A+k0);
	x=min(x,A+l0);
	y=min(y,A+m0);
	z=min(z,A+n0);
	A=min(A,A+o0);
	B=min(B,A+p0);
	C=min(C,A+q0);
	D=min(D,A+r0);
	E=min(E,K+i0);
	F=min(F,K+j0);
	G=min(G,K+k0);
	H=min(H,K+l0);
	I=min(I,K+m0);
	J=min(J,K+n0);
	K=min(K,K+o0);
	L=min(L,K+p0);
	M=min(M,K+q0);
	N=min(N,K+r0);
	O=min(O,U+i0);
	P=min(P,U+j0);
	Q=min(Q,U+k0);
	R=min(R,U+l0);
	S=min(S,U+m0);
	T=min(T,U+n0);
	U=min(U,U+o0);
	V=min(V,U+p0);
	W=min(W,U+q0);
	X=min(X,U+r0);
	Y=min(Y,e0+i0);
	Z=min(Z,e0+j0);
	a0=min(a0,e0+k0);
	b0=min(b0,e0+l0);
	c0=min(c0,e0+m0);
	d0=min(d0,e0+n0);
	e0=min(e0,e0+o0);
	f0=min(f0,e0+p0);
	g0=min(g0,e0+q0);
	h0=min(h0,e0+r0);
	i0=min(i0,o0+i0);
	j0=min(j0,o0+j0);
	k0=min(k0,o0+k0);
	l0=min(l0,o0+l0);
	m0=min(m0,o0+m0);
	n0=min(n0,o0+n0);
	o0=min(o0,o0+o0);
	p0=min(p0,o0+p0);
	q0=min(q0,o0+q0);
	r0=min(r0,o0+r0);
	s0=min(s0,y0+i0);
	t0=min(t0,y0+j0);
	u0=min(u0,y0+k0);
	v0=min(v0,y0+l0);
	w0=min(w0,y0+m0);
	x0=min(x0,y0+n0);
	y0=min(y0,y0+o0);
	z0=min(z0,y0+p0);
	A0=min(A0,y0+q0);
	B0=min(B0,y0+r0);
	C0=min(C0,I0+i0);
	D0=min(D0,I0+j0);
	E0=min(E0,I0+k0);
	F0=min(F0,I0+l0);
	G0=min(G0,I0+m0);
	H0=min(H0,I0+n0);
	I0=min(I0,I0+o0);
	J0=min(J0,I0+p0);
	K0=min(K0,I0+q0);
	L0=min(L0,I0+r0);
	M0=min(M0,S0+i0);
	N0=min(N0,S0+j0);
	O0=min(O0,S0+k0);
	P0=min(P0,S0+l0);
	Q0=min(Q0,S0+m0);
	R0=min(R0,S0+n0);
	S0=min(S0,S0+o0);
	T0=min(T0,S0+p0);
	U0=min(U0,S0+q0);
	V0=min(V0,S0+r0);
	a=min(a,h+s0);
	b=min(b,h+t0);
	c=min(c,h+u0);
	d=min(d,h+v0);
	e=min(e,h+w0);
	f=min(f,h+x0);
	g=min(g,h+y0);
	h=min(h,h+z0);
	i=min(i,h+A0);
	j=min(j,h+B0);
	k=min(k,r+s0);
	l=min(l,r+t0);
	m=min(m,r+u0);
	n=min(n,r+v0);
	o=min(o,r+w0);
	p=min(p,r+x0);
	q=min(q,r+y0);
	r=min(r,r+z0);
	s=min(s,r+A0);
	t=min(t,r+B0);
	u=min(u,B+s0);
	v=min(v,B+t0);
	w=min(w,B+u0);
	x=min(x,B+v0);
	y=min(y,B+w0);
	z=min(z,B+x0);
	A=min(A,B+y0);
	B=min(B,B+z0);
	C=min(C,B+A0);
	D=min(D,B+B0);
	E=min(E,L+s0);
	F=min(F,L+t0);
	G=min(G,L+u0);
	H=min(H,L+v0);
	I=min(I,L+w0);
	J=min(J,L+x0);
	K=min(K,L+y0);
	L=min(L,L+z0);
	M=min(M,L+A0);
	N=min(N,L+B0);
	O=min(O,V+s0);
	P=min(P,V+t0);
	Q=min(Q,V+u0);
	R=min(R,V+v0);
	S=min(S,V+w0);
	T=min(T,V+x0);
	U=min(U,V+y0);
	V=min(V,V+z0);
	W=min(W,V+A0);
	X=min(X,V+B0);
	Y=min(Y,f0+s0);
	Z=min(Z,f0+t0);
	a0=min(a0,f0+u0);
	b0=min(b0,f0+v0);
	c0=min(c0,f0+w0);
	d0=min(d0,f0+x0);
	e0=min(e0,f0+y0);
	f0=min(f0,f0+z0);
	g0=min(g0,f0+A0);
	h0=min(h0,f0+B0);
	i0=min(i0,p0+s0);
	j0=min(j0,p0+t0);
	k0=min(k0,p0+u0);
	l0=min(l0,p0+v0);
	m0=min(m0,p0+w0);
	n0=min(n0,p0+x0);
	o0=min(o0,p0+y0);
	p0=min(p0,p0+z0);
	q0=min(q0,p0+A0);
	r0=min(r0,p0+B0);
	s0=min(s0,z0+s0);
	t0=min(t0,z0+t0);
	u0=min(u0,z0+u0);
	v0=min(v0,z0+v0);
	w0=min(w0,z0+w0);
	x0=min(x0,z0+x0);
	y0=min(y0,z0+y0);
	z0=min(z0,z0+z0);
	A0=min(A0,z0+A0);
	B0=min(B0,z0+B0);
	C0=min(C0,J0+s0);
	D0=min(D0,J0+t0);
	E0=min(E0,J0+u0);
	F0=min(F0,J0+v0);
	G0=min(G0,J0+w0);
	H0=min(H0,J0+x0);
	I0=min(I0,J0+y0);
	J0=min(J0,J0+z0);
	K0=min(K0,J0+A0);
	L0=min(L0,J0+B0);
	M0=min(M0,T0+s0);
	N0=min(N0,T0+t0);
	O0=min(O0,T0+u0);
	P0=min(P0,T0+v0);
	Q0=min(Q0,T0+w0);
	R0=min(R0,T0+x0);
	S0=min(S0,T0+y0);
	T0=min(T0,T0+z0);
	U0=min(U0,T0+A0);
	V0=min(V0,T0+B0);
	a=min(a,i+C0);
	b=min(b,i+D0);
	c=min(c,i+E0);
	d=min(d,i+F0);
	e=min(e,i+G0);
	f=min(f,i+H0);
	g=min(g,i+I0);
	h=min(h,i+J0);
	i=min(i,i+K0);
	j=min(j,i+L0);
	k=min(k,s+C0);
	l=min(l,s+D0);
	m=min(m,s+E0);
	n=min(n,s+F0);
	o=min(o,s+G0);
	p=min(p,s+H0);
	q=min(q,s+I0);
	r=min(r,s+J0);
	s=min(s,s+K0);
	t=min(t,s+L0);
	u=min(u,C+C0);
	v=min(v,C+D0);
	w=min(w,C+E0);
	x=min(x,C+F0);
	y=min(y,C+G0);
	z=min(z,C+H0);
	A=min(A,C+I0);
	B=min(B,C+J0);
	C=min(C,C+K0);
	D=min(D,C+L0);
	E=min(E,M+C0);
	F=min(F,M+D0);
	G=min(G,M+E0);
	H=min(H,M+F0);
	I=min(I,M+G0);
	J=min(J,M+H0);
	K=min(K,M+I0);
	L=min(L,M+J0);
	M=min(M,M+K0);
	N=min(N,M+L0);
	O=min(O,W+C0);
	P=min(P,W+D0);
	Q=min(Q,W+E0);
	R=min(R,W+F0);
	S=min(S,W+G0);
	T=min(T,W+H0);
	U=min(U,W+I0);
	V=min(V,W+J0);
	W=min(W,W+K0);
	X=min(X,W+L0);
	Y=min(Y,g0+C0);
	Z=min(Z,g0+D0);
	a0=min(a0,g0+E0);
	b0=min(b0,g0+F0);
	c0=min(c0,g0+G0);
	d0=min(d0,g0+H0);
	e0=min(e0,g0+I0);
	f0=min(f0,g0+J0);
	g0=min(g0,g0+K0);
	h0=min(h0,g0+L0);
	i0=min(i0,q0+C0);
	j0=min(j0,q0+D0);
	k0=min(k0,q0+E0);
	l0=min(l0,q0+F0);
	m0=min(m0,q0+G0);
	n0=min(n0,q0+H0);
	o0=min(o0,q0+I0);
	p0=min(p0,q0+J0);
	q0=min(q0,q0+K0);
	r0=min(r0,q0+L0);
	s0=min(s0,A0+C0);
	t0=min(t0,A0+D0);
	u0=min(u0,A0+E0);
	v0=min(v0,A0+F0);
	w0=min(w0,A0+G0);
	x0=min(x0,A0+H0);
	y0=min(y0,A0+I0);
	z0=min(z0,A0+J0);
	A0=min(A0,A0+K0);
	B0=min(B0,A0+L0);
	C0=min(C0,K0+C0);
	D0=min(D0,K0+D0);
	E0=min(E0,K0+E0);
	F0=min(F0,K0+F0);
	G0=min(G0,K0+G0);
	H0=min(H0,K0+H0);
	I0=min(I0,K0+I0);
	J0=min(J0,K0+J0);
	K0=min(K0,K0+K0);
	L0=min(L0,K0+L0);
	M0=min(M0,U0+C0);
	N0=min(N0,U0+D0);
	O0=min(O0,U0+E0);
	P0=min(P0,U0+F0);
	Q0=min(Q0,U0+G0);
	R0=min(R0,U0+H0);
	S0=min(S0,U0+I0);
	T0=min(T0,U0+J0);
	U0=min(U0,U0+K0);
	V0=min(V0,U0+L0);
	a=min(a,j+M0);
	b=min(b,j+N0);
	c=min(c,j+O0);
	d=min(d,j+P0);
	e=min(e,j+Q0);
	f=min(f,j+R0);
	g=min(g,j+S0);
	h=min(h,j+T0);
	i=min(i,j+U0);
	j=min(j,j+V0);
	k=min(k,t+M0);
	l=min(l,t+N0);
	m=min(m,t+O0);
	n=min(n,t+P0);
	o=min(o,t+Q0);
	p=min(p,t+R0);
	q=min(q,t+S0);
	r=min(r,t+T0);
	s=min(s,t+U0);
	t=min(t,t+V0);
	u=min(u,D+M0);
	v=min(v,D+N0);
	w=min(w,D+O0);
	x=min(x,D+P0);
	y=min(y,D+Q0);
	z=min(z,D+R0);
	A=min(A,D+S0);
	B=min(B,D+T0);
	C=min(C,D+U0);
	D=min(D,D+V0);
	E=min(E,N+M0);
	F=min(F,N+N0);
	G=min(G,N+O0);
	H=min(H,N+P0);
	I=min(I,N+Q0);
	J=min(J,N+R0);
	K=min(K,N+S0);
	L=min(L,N+T0);
	M=min(M,N+U0);
	N=min(N,N+V0);
	O=min(O,X+M0);
	P=min(P,X+N0);
	Q=min(Q,X+O0);
	R=min(R,X+P0);
	S=min(S,X+Q0);
	T=min(T,X+R0);
	U=min(U,X+S0);
	V=min(V,X+T0);
	W=min(W,X+U0);
	X=min(X,X+V0);
	Y=min(Y,h0+M0);
	Z=min(Z,h0+N0);
	a0=min(a0,h0+O0);
	b0=min(b0,h0+P0);
	c0=min(c0,h0+Q0);
	d0=min(d0,h0+R0);
	e0=min(e0,h0+S0);
	f0=min(f0,h0+T0);
	g0=min(g0,h0+U0);
	h0=min(h0,h0+V0);
	i0=min(i0,r0+M0);
	j0=min(j0,r0+N0);
	k0=min(k0,r0+O0);
	l0=min(l0,r0+P0);
	m0=min(m0,r0+Q0);
	n0=min(n0,r0+R0);
	o0=min(o0,r0+S0);
	p0=min(p0,r0+T0);
	q0=min(q0,r0+U0);
	r0=min(r0,r0+V0);
	s0=min(s0,B0+M0);
	t0=min(t0,B0+N0);
	u0=min(u0,B0+O0);
	v0=min(v0,B0+P0);
	w0=min(w0,B0+Q0);
	x0=min(x0,B0+R0);
	y0=min(y0,B0+S0);
	z0=min(z0,B0+T0);
	A0=min(A0,B0+U0);
	B0=min(B0,B0+V0);
	C0=min(C0,L0+M0);
	D0=min(D0,L0+N0);
	E0=min(E0,L0+O0);
	F0=min(F0,L0+P0);
	G0=min(G0,L0+Q0);
	H0=min(H0,L0+R0);
	I0=min(I0,L0+S0);
	J0=min(J0,L0+T0);
	K0=min(K0,L0+U0);
	L0=min(L0,L0+V0);
	M0=min(M0,V0+M0);
	N0=min(N0,V0+N0);
	O0=min(O0,V0+O0);
	P0=min(P0,V0+P0);
	Q0=min(Q0,V0+Q0);
	R0=min(R0,V0+R0);
	S0=min(S0,V0+S0);
	T0=min(T0,V0+T0);
	U0=min(U0,V0+U0);
	V0=min(V0,V0+V0);
	int _a=0;
	_a=max(_a,a);
	_a=max(_a,b);
	_a=max(_a,c);
	_a=max(_a,d);
	_a=max(_a,e);
	_a=max(_a,f);
	_a=max(_a,g);
	_a=max(_a,h);
	_a=max(_a,i);
	_a=max(_a,j);
	_a=max(_a,k);
	_a=max(_a,l);
	_a=max(_a,m);
	_a=max(_a,n);
	_a=max(_a,o);
	_a=max(_a,p);
	_a=max(_a,q);
	_a=max(_a,r);
	_a=max(_a,s);
	_a=max(_a,t);
	_a=max(_a,u);
	_a=max(_a,v);
	_a=max(_a,w);
	_a=max(_a,x);
	_a=max(_a,y);
	_a=max(_a,z);
	_a=max(_a,A);
	_a=max(_a,B);
	_a=max(_a,C);
	_a=max(_a,D);
	_a=max(_a,E);
	_a=max(_a,F);
	_a=max(_a,G);
	_a=max(_a,H);
	_a=max(_a,I);
	_a=max(_a,J);
	_a=max(_a,K);
	_a=max(_a,L);
	_a=max(_a,M);
	_a=max(_a,N);
	_a=max(_a,O);
	_a=max(_a,P);
	_a=max(_a,Q);
	_a=max(_a,R);
	_a=max(_a,S);
	_a=max(_a,T);
	_a=max(_a,U);
	_a=max(_a,V);
	_a=max(_a,W);
	_a=max(_a,X);
	_a=max(_a,Y);
	_a=max(_a,Z);
	_a=max(_a,a0);
	_a=max(_a,b0);
	_a=max(_a,c0);
	_a=max(_a,d0);
	_a=max(_a,e0);
	_a=max(_a,f0);
	_a=max(_a,g0);
	_a=max(_a,h0);
	_a=max(_a,i0);
	_a=max(_a,j0);
	_a=max(_a,k0);
	_a=max(_a,l0);
	_a=max(_a,m0);
	_a=max(_a,n0);
	_a=max(_a,o0);
	_a=max(_a,p0);
	_a=max(_a,q0);
	_a=max(_a,r0);
	_a=max(_a,s0);
	_a=max(_a,t0);
	_a=max(_a,u0);
	_a=max(_a,v0);
	_a=max(_a,w0);
	_a=max(_a,x0);
	_a=max(_a,y0);
	_a=max(_a,z0);
	_a=max(_a,A0);
	_a=max(_a,B0);
	_a=max(_a,C0);
	_a=max(_a,D0);
	_a=max(_a,E0);
	_a=max(_a,F0);
	_a=max(_a,G0);
	_a=max(_a,H0);
	_a=max(_a,I0);
	_a=max(_a,J0);
	_a=max(_a,K0);
	_a=max(_a,L0);
	_a=max(_a,M0);
	_a=max(_a,N0);
	_a=max(_a,O0);
	_a=max(_a,P0);
	_a=max(_a,Q0);
	_a=max(_a,R0);
	_a=max(_a,S0);
	_a=max(_a,T0);
	_a=max(_a,U0);
	_a=max(_a,V0);
	printf("%d\n", _a);
}

int main() {
	scanf("%d", &_n);
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);
	scanf("%d", &f);
	scanf("%d", &g);
	scanf("%d", &h);
	scanf("%d", &i);
	scanf("%d", &j);
	scanf("%d", &k);
	scanf("%d", &l);
	scanf("%d", &m);
	scanf("%d", &n);
	scanf("%d", &o);
	scanf("%d", &p);
	scanf("%d", &q);
	scanf("%d", &r);
	scanf("%d", &s);
	scanf("%d", &t);
	scanf("%d", &u);
	scanf("%d", &v);
	scanf("%d", &w);
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &z);
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &D);
	scanf("%d", &E);
	scanf("%d", &F);
	scanf("%d", &G);
	scanf("%d", &H);
	scanf("%d", &I);
	scanf("%d", &J);
	scanf("%d", &K);
	scanf("%d", &L);
	scanf("%d", &M);
	scanf("%d", &N);
	scanf("%d", &O);
	scanf("%d", &P);
	scanf("%d", &Q);
	scanf("%d", &R);
	scanf("%d", &S);
	scanf("%d", &T);
	scanf("%d", &U);
	scanf("%d", &V);
	scanf("%d", &W);
	scanf("%d", &X);
	scanf("%d", &Y);
	scanf("%d", &Z);
	scanf("%d", &a0);
	scanf("%d", &b0);
	scanf("%d", &c0);
	scanf("%d", &d0);
	scanf("%d", &e0);
	scanf("%d", &f0);
	scanf("%d", &g0);
	scanf("%d", &h0);
	scanf("%d", &i0);
	scanf("%d", &j0);
	scanf("%d", &k0);
	scanf("%d", &l0);
	scanf("%d", &m0);
	scanf("%d", &n0);
	scanf("%d", &o0);
	scanf("%d", &p0);
	scanf("%d", &q0);
	scanf("%d", &r0);
	scanf("%d", &s0);
	scanf("%d", &t0);
	scanf("%d", &u0);
	scanf("%d", &v0);
	scanf("%d", &w0);
	scanf("%d", &x0);
	scanf("%d", &y0);
	scanf("%d", &z0);
	scanf("%d", &A0);
	scanf("%d", &B0);
	scanf("%d", &C0);
	scanf("%d", &D0);
	scanf("%d", &E0);
	scanf("%d", &F0);
	scanf("%d", &G0);
	scanf("%d", &H0);
	scanf("%d", &I0);
	scanf("%d", &J0);
	scanf("%d", &K0);
	scanf("%d", &L0);
	scanf("%d", &M0);
	scanf("%d", &N0);
	scanf("%d", &O0);
	scanf("%d", &P0);
	scanf("%d", &Q0);
	scanf("%d", &R0);
	scanf("%d", &S0);
	scanf("%d", &T0);
	scanf("%d", &U0);
	scanf("%d", &V0);
	_n == 1 ? solve1() : (_n == 2 ? solve2() : (_n == 3 ? solve3() : (_n == 4 ? solve4() : (_n == 5 ? solve5() : (_n == 6 ? solve6() : (_n == 7 ? solve7() : (_n == 8 ? solve8() : (_n == 9 ? solve9() : (solve10())))))))));
	return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:167772160000")
#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <sstream>
#include <assert.h>
#include <functional>
#include <climits>
#include <cstring>
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;
typedef std::pair<double, double> pdd;
#define ALL(x)           (x).begin(), (x).end()
#define forn(N)          for(int i = 0; i<(int)N; i++)
#define fornj(N)         for(int j = 0; j<(int)N; j++)
#define fornk(N)         for(int k = 0; k<(int)N; k++)
#define forn1(N)          for(int i = 1; i<=(int)N; i++)
#define fornj1(N)         for(int j = 1; j<=(int)N; j++)
#define fornk1(N)         for(int k = 1; k<=(int)N; k++)
#define PI 3.1415926535897932384626433
#define LINF (1LL<<60)
#define INF (1<<30)
#define v vector
#define File "Patterns"
#define ll long long
#define print(n) printf("%d ", (n));
#define printll(n) printf("%I64d", (n));
#define printline() printf("\n");
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair
using namespace std;

int adj[20][20];

int main()
{
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#else
	//freopen(File".in", "r", stdin); freopen(File".out", "w", stdout);
#endif
	int n; cin >> n;
	forn1(n)fornj1(n)cin >> adj[i][j];
	while (1) {
		bool w = 0;
		forn1(n)fornj1(n)fornk1(n) {
			if ((i == j) || (i == k) || (j == k))continue;
			if (adj[i][j] + adj[j][k] < adj[i][k]) {
				adj[i][k] = adj[i][j] + adj[j][k];
				w = 1;
			}

		}
		if (!w)break;
	}
	int answer = 0;
	forn1(n)fornj1(n) answer = max(answer, adj[i][j]);
	cout << answer;
	return 0;

}

#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main()
{
	cout<< 2;

	return 0;
}

#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
// Let's Fight!

#define ZZZ f ## or
#define CON(i, j, k) ZZZ(int i=(j); i<(k); i++)

const int MAXN = 12;

int N;
int dis[MAXN][MAXN];

int main() {
  IOS;

  cin>>N;

  CON(i, 0, N)
    CON(j, 0, N)
      cin>>dis[i][j];

  CON(k, 0, N)
    CON(i, 0, N)
      CON(j, 0, N)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);

  int ans = 0;
  CON(i, 0, N)
    CON(j, 0, N)
      ans = max(ans, dis[i][j]);

  cout<<ans<<endl;

  return 0;
}

#include <bits/stdc++.h>
#defin\
e fo fo\
r

using namespace std;

int n, ans = -0x7fffffff;
int f[20][20];

int main() {
	scanf("%d", &n);
	fo (int i = 1; i <= n; i ++) {
		fo (int j = 1; j <= n; j ++) {
			scanf("%d", &f[i][j]);
		}
	}
	fo (int k = 1; k <= n; k ++)
		fo (int i = 1; i <= n; i ++)
			fo (int j = 1; j <= n; j ++)
				f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
	fo (int i = 1; i <= n; i ++) {
		fo (int j = 1; j <= n; j ++) {
			if (i != j)
				ans = max(ans, f[i][j]);
		}
	}
	printf("%d\n", ans);
	return 0;
}

#include <iostream>

using namespace std;

int A[30][30];
int N;

int ANS = 0;

bool readLine(int U,int x){
    cin >> A[U][x];
    x++;
    return (x!=N)  && readLine(U,x);
}

bool read(int U){
    readLine(U,0);
    U++;
    return (U!=N)  && read(U);
}

bool ffri(int i, int j, int k){
    A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
    k++;
    return  (k!=N) && ffri(i,j,k);
}

bool ffri(int i, int j){
    ffri(i,j,0);
    j++;
    return  (j!=N) && ffri(i,j);
}

bool ffri(int i){
    ffri(i,0);
    i++;
    return  (i!=N) && ffri(i);
}

bool Ffri(int i, int j){
    //clog << i <<" "<<j<<endl;
    ANS = max(ANS, A[i][j]);
    j++;
    return  (j!=N) && Ffri(i,j);
}

bool Ffri(int i){
    Ffri(i,i+1);
    i++;
    return  (i!=N-1) && Ffri(i);
}

int main(){
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    read(0);

    ffri(0);

    Ffri(0);
    cout << ANS;
    return 0;
}

#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <stack>
#include <string>
#include <queue>

using namespace std;

#define ABS(a) (((a) > 0)? (a): -(a))
#define MIN(a, b) (((a) < (b))? (a): (b))
#define MAX(a, b) (((a) < (b))? (b): (a))
#define MFOR(i, a, n) for (int i = (a); i < (n); i++)
#define FOR(i, a, n) for (int i = (a); i <= (n); i++)
#define DFOR(i, a, n) for (int i = (a); i >= (n); i--)
#define SQR(a) (a) * (a)
#define All(a) (a).begin(), (a).end()
#define PI 3.1415926535897932384626433832795
#define MEMS(a, b) memset((a), (b), sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'
#define LL long long
#define UN unsigned
#define Or ||
#define And &&
/////////////////////////////////////////////

void solution()
{
	int n, m[22], r[22];
	cin >> n;
	FOR(i, 1, n)
		cin >> m[i];
	FOR(i, 1, n)
		cin >> r[i];

	int ans = 0;
	FOR(i, 1, 1000000)
	{
		FOR(j, 1, n)
		{
			if (i % m[j] == r[j])
			{
				ans++;
				break;
			}
		}
	}
	int x = 1000000;
	if (ans != 1000000)
	{
		cout << "0.";
		x /= 10;
		while (x > ans)
		{
			cout << "0";
			x /= 10;
		}
		cout << ans << endl;
	}
	else
		cout << "1.00000000" << endl;
}

/*-------------------*/

int main()
{
#ifdef Files
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
/*Test*/
//freopen("input.txt", "w", stdout);
long double OcZ2X = clock();
#else
//freopen("laboratory.in", "r", stdin);
//freopen("laboratory.out", "w", stdout);
#endif
/*
 　　　　　　　　　　　 　∧__∧
　　　　　　　　　　　 　( ° ͜ʖ°)
　　　　　　　　　　　 　⊂　　 つ
　　　　　　　　　　　　　(つ ﾉ
　　　　　　　　　　　　　 (ノ
　　　　　＼　　　　　　☆
　　　　　　　　　　　　　|　　　　　☆
　　　　　　　　　　(⌒ ⌒ヽ　　　/
　　　　＼　　（´⌒　　⌒　　⌒ヾ　　　／
　　　　　 （’⌒　;　⌒　　　::⌒　　）
　　　　　（´*/    solution();   /*:::　）　／
　　☆─　（´⌒;:　　　　::⌒`）　:;　　）
　　　　　（⌒::　　　::　　　　　::⌒　）
　　 　／　（　　　　ゝ　　ヾ　丶　　ソ　─
*/
#ifdef Time
long double P2HxQ = clock();
printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

#include<bits/stdc++.h>

int n, a[15][15];

int scan(int i, int j, int n) {
	scanf("%d", &a[i][j]);
	return j + 1 < n ? scan(i, j + 1, n) : i + 1 < n ? scan(i + 1, 0, n) : 0;
}

int wtf(int k, int i, int j, int n) {
	a[i][j] = std::min(a[i][j], a[i][k] + a[j][k]);
	return k + 1 < n ? wtf(i, j, k + 1, n) : j + 1 < n ? wtf(i, j + 1, 0, n) : i + 1 < n ? wtf(i + 1, 0, 0, n) : 0;
}

int ftw(int i, int j, int n) {
	return std::max(a[i][j], j + 1 < n ? ftw(i, j + 1, n) : i + 1 < n ? ftw(i + 1, 0, n) : 0);
}

int main() {
	scanf("%d", &n);
	scan(0, 0, n);
	wtf(0, 0, 0, n);
	printf("%d\n", ftw(0, 0, n));
	scanf("\n");
	return 0;
}

#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <functional>

using namespace std;

typedef long long int   ll;
typedef double     ld;
typedef	pair<int, int>	ii;
typedef	vector<int>		vi;
typedef	vector<ii>		vii;

const int MAXN = 100;
const int MAXM = 200000;
const int INF = 1000000010;
const ll MOD = 1000000007;
const ll P = 31;
const ld EPS = 1e-6;

int N;
int dp[MAXN][MAXN][MAXN];
int pi, pj, pk;
int ans;

void dummy(int code) {
	return;
}

void iterj(int code) {
	ans = max(ans, dp[N][pi][pj]);

	pj++;
	(pj < N ? iterj : dummy)(0);
}

void iteri(int code) {
	pj = 0;
	iterj(0);

	pi++;
	(pi < N ? iteri : dummy)(0);
}

void iter_pj(int code) {
	dp[pk][pi][pj] = min(dp[pk - 1][pi][pj], (pi != pk-1 && pj != pk-1 ? dp[pk - 1][pi][pk-1] + dp[pk - 1][pk-1][pj] : INF));

	pj++;
	(pj < N ? iter_pj : dummy)(0);
}

void iter_pi(int code) {
	pj = 0;
	iter_pj(0);
	pi++;
	(pi < N ? iter_pi : dummy)(0);
}

void iter_pk(int code) {
	pi = 0;
	iter_pi(0);
	pk++;
	(pk <= N ? iter_pk : dummy)(0);
}

void read_line(int code) {
	scanf("%d", &dp[0][pi][pj]);

	pj++;
	(pj < N ? read_line : dummy)(0);
}

void read(int code) {
	pj = 0;
	read_line(0);

	pi++;
	(pi < N ? read : dummy)(0);
}

int main() {
#ifdef  FILE_IO
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("happy.in", "r", stdin);
	//freopen("happy.out", "w", stdout);
#endif // FILE_IO
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	pi = pj = 0;
	scanf("%d", &N);

	read(0);

	pk = 1;
	iter_pk(0);

	ans = 0;
	pi = 0;
	iteri(0);

	printf("%d", ans);

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 10;

int it[N];

int main() {
	int F, I, T;
	cin >> F >> I >> T;

	int ret = 0;
	char c;
	for (int i = 0; i < F; i++) {
		for (int j = 0; j < I; j++) {
			cin >> c;
			if (c == 'N') continue;
			else if (++it[j] == T) {
				ret += 1;
			}
		}
	}

	cout << ret << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define F(i,j,k) for(i=j;i<=k;i++)
int dis[20][20];
int Floyd(int n)
{
	int i,j,k;
	F(k,1,n)
		F(i,1,n)
			F(j,1,n)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int ans=0;
	F(i,1,n)
		F(j,1,n)
			ans=max(ans,dis[i][j]);
	return ans;
}
int main()
{
	int n,i,j;
	cin>>n;
	F(i,1,n)
		F(j,1,n)
			cin>>dis[i][j];
	cout<<Floyd(n)<<"\n";
}

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstdio>
#include<string.h>
#include<map>
#include<queue>
#include<math.h>
#include<bitset>
#define INF 0x3f3f3f3f
#define maxn 100005
#define F fo\
r
using namespace std;
int G[15][15]={0};
int main()
{
    int n;
    scanf("%d",&n);
    F(int i=0;i<n;i++)
     F(int j=0;j<n;j++)
     {
         scanf("%d",&G[i][j]);
     }
    F(int k=0;k<n;k++)
    {
        F(int i=0;i<n;i++)
        {
            F(int j=0;j<n;j++)
            {
                G[i][j]=(G[i][k]+G[k][j]<G[i][j])?(G[i][k]+G[k][j]):G[i][j];
            }
        }
    }
    int ans=0;
    F(int i=0;i<n;i++)
     F(int j=0;j<n;j++)
        ans=max(G[i][j],ans);
    printf("%d\n",ans);
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

/****************************define***************************************/

const int N = 20 + 100;

int a[N][N], ans;

int readLine(int curRow, int curCol, int cols) {
    cin >> a[curRow][curCol];
    return curCol+1==cols?0:readLine(curRow, curCol + 1, cols);
}

int readData(int curRow, int rows, int curCol, int cols) {
    readLine(curRow, 0, cols);
    return curRow+1==rows?0:readData(curRow + 1, rows, curCol, cols);
}

int floydLoop3(int k, int i, int j, int end) {
    a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
    return j+1==end?0:floydLoop3(k, i, j + 1, end);
}

int floydLoop2(int k, int i, int end) {
    floydLoop3(k, i, 0, end);
    return i+1==end?0:floydLoop2(k, i + 1, end);
}

int floydLoop1(int k, int end) {
    floydLoop2(k, 0, end);
    return k+1==end?0:floydLoop1(k + 1, end);
}

int getAns2(int i, int j, int end) {
    ans = max(ans, a[i][j]);
    return j+1==end?0:getAns2(i, j + 1, end);
}

int getAns(int i, int end) {
    getAns2(i, 0, end);
    return i+1==end?0:getAns(i + 1, end);
}

int main() {
    int n;
    cin >> n;

    readData(0, n, 0, n);

    floydLoop1(0, n);

    getAns(0, n);

    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int n,in[120][120],ans=0;
void fool(){;}
void input2(int a,int b)
{
    b?(scanf("%d",in[a]+(n+1-b)),input2(a,b-1)):fool();
}
void input(int a)
{
    a?(input2(n+1-a,n),input(a-1)):fool();
}
void update(int a,int b)
{
    ans=max(ans,in[a][b]);
}
void _slack(int x,int a,int b)
{
    in[a][b]=min(in[a][b],in[a][x]+in[x][b]);
}
void slake (int x,int a,int b)
{
    (x!=a&&x!=b&&a!=b)?_slack(x,a,b):fool();
}
void gao3(int x,int a,int b)
{
    (!b)?fool():(slake(x,a,b),gao3(x,a,b-1));
}
void gao2(int x,int a)
{
    (!a)?fool():(gao3(x,a,n),gao2(x,a-1));
}
void gao(int x)
{
    (!x)?fool():(gao2(x,n),gao(x-1));
}
void getans2(int a,int b)
{
    b?(update(a,b),getans2(a,b-1)):fool();
}
void getans(int a)
{
    a?getans2(a,n):fool();
}
int main()
{
    scanf("%d",&n);
    input(n);
    gao(n);
    getans(n);
    printf("%d\n",ans);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using ld = long double;
using pii = pair<int, int>;

#define filename "";

template <class F> void bleh(int i, int n, const F &f)
{
	f(i); poop(i + 1, n, f);
}

template <class F> void poop(int i, int n, const F &f)
{
	return (i == n) ? void() : bleh(i, n, f);
}

void solve()
{
	int n;
	cin >> n;

	ll oo = (ll)1e9;
	vector<vector<ll>> d(n, vector<ll>(n, oo));

	poop(0, n, [&](int i) {
		d[i][i] = 0;
	});

	poop(0, n, [&](int i) {
		poop(0, n, [&](int j){
			cin >> d[i][j];
		});
	});

	ll ans = 0;
	poop(0, n, [&](int k){
		poop(0, n, [&](int i){
			poop(0, n, [&](int j){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

				ans = (d[i][j] < oo) ? max(ans, d[i][j]) : ans;
			});
		});
	});

	cout << ans << '\n';
}

int main()
{
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	// freopen(filename ".in", "r", stdin); freopen(filename ".out", "w", stdout);

	solve();

	return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[20][20];
#define Fo(i,a,b) for(int i=a;i<b;i++)
int main()
{
    while(scanf("%d",&n)!=EOF)
    {

        Fo(i,0,n)
        //for(int i=0;i<n;i++)
        {
            Fo(j,0,n)
            scanf("%d",&a[i][j]);
        }

        Fo(k,0,n)
        {

            Fo(i,0,n)
            {

                Fo(j,0,n)
                {

                    a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
                }
            }
        }
        int ans=0;
        Fo(i,0,n)
        {
            Fo(j,0,n)
            {
                ans=max(ans,a[i][j]);
            }

        }
        printf("%d\n",ans);
    }

    return 0;
}

#include<bits/stdc++.h>
#define FOR(i,j,k)  for(int i=(j);i<=(k);i++)
using namespace std;
int a[11][11],n;
int main()
{
	scanf("%d",&n);
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
cin>>a[i][j];
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
int ans=-2e9;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	ans=max(ans,a[i][j]);
cout<<ans;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
#def\
ine FOR fo\
r
#def\
ine IF i\
f
int mat[11][11];
void floyd_warshal(int v)
{
    FOR(int k=1;k<=v;k++)
    {
        FOR(int i=1;i<=v;i++)
        {
            FOR(int j=1;j<=v;j++)
            {
                IF(mat[i][j]>mat[i][k]+mat[k][j])
                {

                    mat[i][j]=mat[i][k]+mat[k][j];
                 //  cout<<mat[i][j]<<" "<<k<<endl;
                }
            }
           // cout<<endl;
        }
      //  cout<<endl;
    }
}
int main()
{
    int n;
    cin>>n;
    FOR(int i=1;i<=n;i++)
    {
        FOR(int j=1;j<=n;j++)
        {
            cin>>mat[i][j];
        }
    }
    floyd_warshal(n);
    int ans=-1;
     FOR(int i=1;i<=n;i++)
    {
        FOR(int j=1;j<=n;j++)
        {
            ans=max(ans,mat[i][j]);
        }
    }
    cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

int graph[12][12];

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ )
        for ( int j = 0; j < n; j++ )
            cin >> graph[i][j];

    for ( int k = 0; k < n; k++ ){
        for ( int i = 0; i < n; i++ ){
            for ( int j = 0; j < n; j++ ){
                if ( graph[i][j] > graph[i][k] + graph[k][j] )
                    graph[i][j] = graph[i][k] + graph[k][j];
            }
        }
    }

    int resp = 0;
    for ( int i = 0; i < n; i++ ){
        for ( int j = 0; j < n; j++ ){
            resp = max(resp, graph[i][j]);
        }
    }
    cout << resp << endl;

    return 0;
}

#include<iostream>
using namespace std;
int a[111][111],n,ans;
inline int max(int x,int y)
{
	if(x>y)
		return x;
	return y;
}
inline int min(int x,int y)
{
	if(x<y)
		return x;
	return y;
}
int main()
{
cin>>n;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;+j++)
cin>>a[i][j];
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;++j)
	ans=max(ans,a[i][j]);
	cout<<ans<<endl;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

const int N=1e5+5;
const int mod=1e9+7;
const int inf=1e9+7;

int i,j,n,s,ans;
int A[15][15];

int scan(){
	scanf("%d",A[i]+j);
//	A[i][j]=(A[i][j]==0?inf/3:A[i][j]);
//	A[i][j]=(i==j?0:A[i][j]);
	s++;
	j++;
	i+=(j==n+1?1:0);
	j=(j==n+1?1:j);
	return s==n*n?1:scan();
}

int first(int x);
int second(int x,int y);
int third(int x,int y,int z);

int ssecond(int x,int y);

int third(int x,int y,int z){
	A[x][y]=(z==n+1?A[x][y]:min(A[x][y],A[x][z]+A[z][y]));
	return z==n+1?second(x,y+1):third(x,y,z+1);
}

int second(int x,int y){
	return y==n+1?first(x+1):third(x,y,1);
}

int first(int x){
	return x==n+1?1:second(x,1);
}

int sfirst(int x){
	return x==n+1?1:ssecond(x,1);
}

int ssecond(int x,int y){
	ans=(y==n+1?ans:max(ans,A[x][y]));
	return y==n+1?sfirst(x+1):ssecond(x,y+1);
}

main(){

	scanf("%d",&n);

	i=1;
	j=1;

	scan();

	first(1);

	sfirst(1);

	printf("%d",ans);
}

#include <bits/stdc++.h>
using namespace std;
int dis[20][20];
int Floyd(int n)
{
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			ans=max(ans,dis[i][j]);
	return ans;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>dis[i][j];
	cout<<Floyd(n)<<"\n";
}

#include<bits/stdc++.h>
#defin\
e rep \
f\
o\
r
int E[20][20];
int main() {
	int n,ans=0;
	scanf("%d",&n);
	rep (int i=1; i<=n; i++)
		rep (int j=1; j<=n; j++)
			scanf("%d",&E[i][j]);
	rep (int k=1; k<=n; k++)
		rep (int i=1; i<=n; i++)
			rep (int j=1; j<=n; j++){
				if(E[i][k]+E[k][j]<E[i][j])
					E[i][j]=E[i][k]+E[k][j];
			}
	rep (int i=1; i<=n; i++)
		rep (int j=1; j<=n; j++){
			if(E[i][j]>ans)
				ans=E[i][j];
		}
	printf("%d",ans);
}

#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {

	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int dis[20][20],a,b,c,n,maxn=0;
int main()
{
	memset(dis,0x3f,sizeof(dis));
	cin>>n;
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	{
		cin>>a;
		dis[i][j]=a;
		dis[j][i]=a;
	}
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
f\
o\
r(int k=1;k<=n;k++)
	dis[j][k]=min(dis[j][i]+dis[i][k],dis[j][k]);
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
	if(dis[i][j]!=0x3f)
		maxn=max(dis[i][j],maxn);
	cout<<maxn;
	return 0;
}

#include <stdio.h>
#include <algorithm>
using namespace std;
int a[110][110],n,ans,i,j,k;
int main () {
	scanf ("%d",&n);
	for (i=1;i<=n;++i)//ahkjdhkjshdkjhskjdhksjhdsd
		for (j=1;j<=n;++j)
			scanf ("%d",&a[i][j]);//duru
	for (k=1;k<=n;++k)
		for (i=1;i<=n;++i)//ashjahskjhkjas
			for (j=1;j<=n;++j)
				a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
	for (i=1;i<=n;++i)//jkhakjshkjashkjhaskja
		for (j=1;j<=n;++j)//sahkjshakjshkjahksjhkjas
			ans=max(ans,a[i][j]);
	printf ("%d\n",ans);
	return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long double ld;

// Constants
const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-11;

// Types
typedef signed   long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;

int n;
int d[10][10];
//read
bool rec1(int i, int j)
{
	j--;
	cin >>d[i][j];
	j>0?rec1(i,j):0;
}

bool rec2(int i, int j)
{
	i--;
	rec1(i,j);
	i>0?rec2(i,j):0;
}
//floyd
bool rec3(int i, int j, int k)
{
	cerr <<i<<' '<<j<<' '<<k<<endl;
	i--;
	(d[k][j]>d[k][i]+d[i][j])?(d[k][j]=d[k][i]+d[i][j]):0;
	i>0?rec3(i,j,k):0;
}

bool rec4(int i, int j, int k)
{
	j--;
	rec3(i,j,k);
	j>0?rec4(i,j,k):0;
}

bool rec5(int i, int j, int k)
{
	k--;
	rec4(i,j,k);
	k>0?rec5(i,j,k):0;
}

int res=-1;
//max
bool rec6(int i, int j)
{
	j--;
	res<d[i][j]?res=d[i][j]:0;
	j>0?rec6(i,j):0;
}

bool rec7(int i, int j)
{
	i--;
	rec6(i,j);
	i>0?rec7(i,j):0;
}

int main()
{
	cin >>n;
	rec2(n,n);
	rec5(n,n,n);

	rec7(n,n);
	cout <<res;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0,f=1;
	register char c=getchar();
	while(!isdigit(c)){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=(x<<3)+(x<<1)+(c^48);
		c=getchar();
	}
	return x*f;
}
int a[101][101];
int main(){
    int n=read(),ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin>>a[i][j];
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
    for(register int i=1;i<=n;i++)
        for(register int j=1;j<=n;j++)
            ans=max(ans,a[i][j]);
    cout<<ans<<endl;
    return 0;
}//Floyd水紫题

//God & me
//Damned if Amirjoon doesn't take what he wants.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

const int maxn=2e1+17;
int n,w[maxn][maxn];
void DeemoLovesInit(){
    int i=0;
 getinp:
    i == n*n ? 17 : ({
	    cin>>w[i/n][i%n];
	    i++;
	    goto getinp;
	    17;
	});
}
void make_amirjoon_happy(){
    int k=0;
 K:
    k == n ? 17 : ({
	    int i=0;
	I:
	    i == n ? 17 : ({
		    int j=0;
		J:
		    j == n ? 17 : ({
			    w[i][j] = w[i][j] > w[i][k] + w[k][j] ? w[i][k] + w[k][j] : w[i][j];
			    j++;
			    goto J;
			    17;
			});
		    i++;
		    goto I;
		    17;
		});
	    k++;
	    goto K;
	    17;
	});
}
int ans=0;
void hamid(){
    int i=0;
 getans:
    i == n*n ? 17 : ({
	    ans = ans > w[i/n][i%n] ? ans : w[i/n][i%n];
	    i++;
	    goto getans;
	    17;
	});
}
main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n;
    DeemoLovesInit();
    make_amirjoon_happy();
    hamid();
    cout<<ans<<'\n';
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define N 15
int n,f[N][N],ans;
int main(){
scanf("%d",&n);
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
scanf("%d",&f[i][j]);
f\
o\
r(int k=1;k<=n;k++)
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
f\
o\
r(int i=1;i<=n;i++)
f\
o\
r(int j=1;j<=n;j++)
ans=max(ans,f[i][j]);
printf("%d",ans);
return 0;
}//qwq qwq

#include <bits/stdc++.h>
#def\
ine F\
(x, y, z) fo\
r (int x = (y); x < (z); ++x)
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector <vector <int>> v(n, vector <int> (n));
    F (i, 0, n) {
        F (j, 0, n) {
            cin >> v[i][j];
        }
    }
    F (k, 0, n) {
        F (i, 0, n) {
            F (j, 0, n) {
                v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
            }
        }
    }
    int res = 0;
    F (i, 0, n) {
        F (j, 0, n) {
            res = max(res, v[i][j]);
        }
    }
    cout << res;
}
/* FOR */

#include <bits/stdc++.h>
using namespace std;

int n;
int a[20][20];

void solve() {
	cin>>n;
	int i = 0;
	while (i++ < n);
//	for (int i = 0; i < n; i++) {
//		for (int j = 0; j < n; j++) {
//			cin>>a[i][j];
//		}
//	}
//	int ans = 0;
//	for (int i = 0; i < n; i++) {
//		for (int j = 0; j < n; j++) {
//			for (int k = 0; k < n; k++) {
//				a[i][j] > a[i][k] + a[k][j] ? a[i][j] = a[i][k] + a[k][j] : 1;
//			}
//			ans < a[i][j] ? ans = a[i][j] : 1;
//		}
//	}
//	cout<<ans<<"\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define TASK ""
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define for1(i, n) for (int i = 1; i <= (int)n; i++)
#define forq(i, s, t) for (int i = s; i <= (int)t; i++)
#define ford(i, s, t) for (int i = s; i >= (int)t; i--)
#define mk make_pair
#define pk	push_back
#define all(v) v.begin(), v.end()
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

const double EPS = 1e-15;
const double PI = acos(-1.0);
const int MAXN = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
const ll LINF = (ll)2e18 + 7;
const int MOD = (int)1e9 + 7;
const ull P = 239017;
const ull MM = (ull)2147482661;

int solve();

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("test.txt", "w", stderr);
	double tstart = TIME;
#else
	//freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
	return solve();
}

int d[100][100];

int solve()
{
	int n;
	cin >> n;
	forn(i, n) {
		forn(j, n) {
			cin >> d[i][j];
		}
	}
	forn(k, n) {
		forn(i, n) {
			forn(j, n) {
				uin(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int answer = 0;
	forn(i, n) {
		forn(j, n) {
			uax(answer, d[i][j]);
		}
	}
	cout << answer;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)
#define endl '\n'
#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)
#define mp make_pair
#define nd second
#define st first
#define type(x) __typeof(x.begin())

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 2e5 + 5;

int n, m, arr[123][123], ans = 0;

void getline(int y, int x) {
	scanf("%d", &arr[y][x]);
	(x > 1 ? (getline(y, x-1)) : void(1));
}

void go(int x) {
	getline(x, n);
	(x > 1 ? (go(x-1)) : void(0));
}

void sp3(int k, int i, int j) {
	arr[i][j] = min(arr[i][j], arr[i][k] + arr[k][j]);
	(j > 1 ? (sp3(k, i, j - 1)) : void(0));
}

void sp2(int k, int i) {
	sp3(k, i, n);
	(i > 1 ? (sp2(k, i - 1)) : void(0));
}

void sp1(int k) {
	sp2(k, n);
	(k > 1 ? (sp1(k-1)) : void(0));
}

void mn2(int k, int i) {
	ans = max(ans, arr[k][i]);
	(i > 1 ? (mn2(k, i - 1)) : void(0));
}

void mn1(int k) {
	mn2(k, n);
	(k > 1 ? (mn1(k-1)) : void(0));
}

int main() {

	scanf("%d", &n);

	go(n);

	sp1(n);

	mn1(n);

	cout << ans << endl;

	return 0;
}

#include <algorithm>
#include <csetjmp>
#include <iostream>

using namespace std;

template <class F1, class F2>
void While(F1 cond, F2 f) {
    jmp_buf b;
    setjmp(b) == 0 && cond() ? longjmp(b, 1) : void();
    f();
    cond() ? longjmp(b, 1) : void();
}

template <class F>
void For(int start, int end, F f) {
    While([&]() { return start < end; }, [&]() {
        f(start++);
    });
}

int a[10][10];

int main() {
    int n;
    While([&]() -> bool { return cin >> n; }, [&]() {
        For(0, n, [&](int i) {
            For(0, n, [&](int j) {
                cin >> a[i][j];
            });
        });
        For(0, n, [&](int k) {
            For(0, n, [&](int i) {
                For(0, n, [&](int j) {
                    a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
                });
            });
        });
        int result = 0;
        For(0, n, [&](int i) {
            result = max(result, *max_element(a[i], a[i] + n));
        });
        cout << result << '\n';
    });
}

#include <bits/stdc++.h>
using namespace std;
#d\
e\
f\
i\
n\
e\
 \
f\
r\
 \
f\
o\
r
int graph[12][12],n;
int floyd(){
    fr(int k=0;k<n;k++){
        fr(int i=0;i<n;i++){
            fr(int j=0;j<n;j++){
                graph[i][j]=(graph[i][j]>graph[i][k]+graph[k][j])?graph[i][k]+graph[k][j]:graph[i][j];
            }
        }
    }
    int ans=0;
    fr(int i=0;i<n;i++){
        fr(int j=0;j<n;j++){
            ans=max(ans,graph[i][j]);
        }
    }
    return ans;
}
int main(){
    while(1==scanf("%d",&n)){
        fr(int i=0;i<n;i++)fr(int j=0;j<n;j++)scanf("%d",&graph[i][j]);
        cout<<floyd()<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int x = n==3?2:(n==4?5:(n==10?64:(n%2?--n:++n)));
    cout<<x<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int A;
int B;
int C;

int gm=0;
bool F=false;

int a();
int b();
int c();
int e();

int L[11][11];

int N;
int X=0,Y=0;

int a() {
    b();
    B=0;
    A++;
    return A==N?0:a();
}

int b() {
    c();
    C=0;
    B++;
    return B==N?0:b();
}

int c() {
    if(!F) {
        L[B][C] = min(L[B][C], L[B][A]+L[A][C]);
    } else {
        gm = max(gm, L[B][C]);
    }
    C++;
    return C==N?0:c();
}

int d() {
    e();
    X=0;
    Y++;
    return Y==N?0:d();
}

int e() {
    int node;
    cin >> node;
    L[Y][X] = node;
    X++;
    return X==N?0:e();
}

int main() {
    cin >> N;
    d();
    F=false;
    a();
    A=0;
    B=0;
    C=0;
    F=true;
    a();
    cout<<gm<<endl;
    return 0;
}

#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main()
{char[] c="efinedoforforeachwhilerepeatuntilifthenelseelifelsifelseifcaseswitch";
	int n=0;
	scanf("%d",&n);
	int a[10][10];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int q=30;
	while(q-->=0)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i!=j)
				{
					for(int l=0;l<n;l++)
					{
						if(l!=j && l!=i)
						{
							if(a[i][l]+a[l][j]<a[i][j])
							{
								a[i][j]=a[j][i]=a[i][l]+a[l][j];
							}
						}

					}
				}
			}
		}
	}
	int r=0;

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			r=(r>=a[i][j])?r:a[i][j];
		}
	}
	cout<< r;

	return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int> > dis(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> dis[i][j];
		}
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (dis[i][k] + dis[k][j] < dis[i][j]) {
					dis[i][j] = dis[i][k] + dis[k][j];
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j)
			ans = max(ans, dis[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <ctime>
#include <set>
using namespace std;
const int N=12;

int g[N][N];
int dis[N][N];
void floyd(int n) {
    memcpy(dis,g,sizeof g);
    for (int k=1; k<=n; k++){
        for (int i=1; i<=n; i++){
            for (int j=1; j<=n; j++) {
                if (dis[i][j]>dis[i][k]+dis[k][j])
                    dis[i][j]=dis[i][k]+dis[k][j];
            }
        }
    }
}
int main () {
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=n;j++) {
            cin>>g[i][j];
        }
    }
    floyd(n);
    int ret=0;
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=n;j++) {
            if (i==j) continue;
            ret=max(ret,dis[i][j]);
        }
    }
    cout<<ret<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define str string
#define dou double
using namespace std;

const int maxn=20;
int n;
int floyed[maxn][maxn];
int mas;

int main()
{
    cin>>n;
f\
o\
r(int i=1;i<=n;i++)
{
f\
o\
r(int q=1;q<=n;q++)
{
    cin>>floyed[i][q];
}
}
f\
o\
r(int i=1;i<=n;i++)
{
f\
o\
r(int k=1;k<=n;k++)
{
f\
o\
r(int q=1;q<=n;q++)
{
i\
f(i==q)
{
    continue;
}
i\
f(floyed[i][k]+floyed[k][q]<floyed[i][q])
{
    floyed[i][q]=floyed[i][k]+floyed[k][q];
    floyed[q][i]=floyed[i][k]+floyed[k][q];
}
}
}
}
f\
o\
r(int i=1;i<=n;i++)
{
f\
o\
r(int q=1;q<=n;q++)
{
i\
f(i==q)
{
    continue;
}
    mas=max(floyed[i][q],mas);
}
}
    cout<<mas;
    return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

#defin\
e da\
s fo\
r

using namespace std;

inline int read() {
    char c = getchar(); int x = 0, f = 1;
    das (; c > '9' || c < '0'; c = getchar()) if (c == '-') f = -1;
    das (; c >='0' && c <='9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
    return x * f;
}

int a[100][100];
int n, ans;

void djj () {
    n = read();
    das (register int i = 1; i <= n; i ++)
        das (register int j = 1; j <= n; j ++)
            a[i][j] = read();
    das (register int k = 1; k <= n; k ++)
        das (register int i = 1; i <= n; i ++)
            das (register int j = 1; j <= n; j ++)
                if (a[i][j] > a[i][k] + a[k][j])
                    a[i][j] = a[i][k] + a[k][j];
}

void lxy () {
    das (register int i = 1; i <= n; i ++)
        das (register int j = i; j <= n; j ++)
            ans = max (ans, a[i][j]);
    printf ("%d\n", ans);
}

void djj_lxy () {
    djj (), lxy ();
}

int main() {
    djj_lxy ();
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cassert>
#include<climits>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<numeric>
#include<iomanip>
#include<bitset>
#include<sstream>
#include<fstream>
#define debug puts("-----")
#define pi (acos(-1.0))
#define eps (1e-8)
#define inf (1<<30)
#define INF (1ll<<62)
using namespace std;
const int NV=15;
int g[NV][NV];
void init(int n,int m)
{
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
        {
            g[i][j]=inf;
            if (i==j) g[i][j]=0;
        }
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            cin>>g[i][j];
}
void floyd_warshall(int n)
{
    for (int k=1; k<=n; k++)
        for (int i=1; i<=n; i++)
            for (int j=1; j<=n; j++)
                if (g[i][k]!=inf&&g[k][j]!=inf&&g[i][k]+g[k][j]<g[i][j])
                    g[i][j]=g[i][k]+g[k][j];
}
int main()
{
    int n;
    cin>>n;
    init(n,n*n);
    floyd_warshall(n);
    int ans=0;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            ans=max(ans,g[i][j]);
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(1==scanf("%d",&n)){
        int d[n][n];
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)scanf("%d",&d[i][j]);
        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                }
            }
        }
        int ans=0;
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(d[i][j]>ans)ans=d[i][j];
        cout<<ans<<endl;
    }
    return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;//hhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
int n,ans,map[11][11];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)	scanf("%d",&map[i][j]);
	}
	for(int k=1;k<=n;++k)
	{
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=n;++j)	map[i][j]=min(map[i][j],map[i][k]+map[k][j]);
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)	ans=max(ans,map[i][j]);
	}
	printf("%d",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int g[50][50];
int n;

int read ( int i, int j ) {
  return ( i == n ) ? 0 : (
    ( cin >> g[i][j] ),
        g[i][i] = 0,
        j++,
        i += j/n, j%= n,
        read ( i, j ) );
}

int floyd ( int i, int j, int k ) {
  return i == n ? 0 : (
    g[i][j] = min ( g[i][k] + g[k][j], g[i][j] ),
    k++,
    j += k/n, k%= n,
    i += j/n, j%= n,
    floyd ( i, j, k ) );
}

int solve ( int i, int j ) {
  return i == n ? 0: max ( g[i][j], solve ( i + (j+1)/n, (j+1)%n ) );
}

int main()
{
  cin >> n;
  read(0,0);
  floyd(0,0,0);
  cout << solve(0,0) << endl;
  return 0;
}

#pragma comment(linker, "/STACK:134217728")
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <complex>
#include <functional>
#include <cmath>
#include <time.h>

using namespace std;

typedef long long LL;

int n;

int G[10][10];
int s;
vector<int> a;

void fork(int i, int j)
{
	int k = 0;

	try
	{
	next_k:

		G[j][k] = min(G[j][i] + G[i][k], G[j][k]);

		k++;
		s = a.at(n - k - 1);
		goto next_k;
	}
	catch (exception e)
	{
		return;
	}
}

void forj(int i)
{
	int j = 0;

	try
	{
	next_j:

		fork(i, j);

		j++;
		s = a.at(n - j - 1);
		goto next_j;
	}
	catch (exception e)
	{
		return;
	}
}

void fori()
{
	int i = 0;

	try
	{
	next_i:

		forj(i);

		i++;
		s = a.at(n - i - 1);
		goto next_i;
	}
	catch (exception e)
	{
		return;
	}
}

void readj(int i)
{
	int j = 0;

	try
	{
	next_j:

		cin >> G[i][j];

		j++;
		s = a.at(n - j - 1);
		goto next_j;
	}
	catch (exception e)
	{
		return;
	}
}

void readi()
{
	int i = 0;

	try
	{
	next_i:

		readj(i);

		i++;
		s = a.at(n - i - 1);
		goto next_i;
	}
	catch (exception e)
	{
		return;
	}
}

int res = 0;

void resj(int i)
{
	int j = 0;

	try
	{
	next_j:

		res = max(res, G[i][j]);

		j++;
		s = a.at(n - j - 1);
		goto next_j;
	}
	catch (exception e)
	{
		return;
	}
}

void resi()
{
	int i = 0;

	try
	{
	next_i:

		resj(i);

		i++;
		s = a.at(n - i - 1);
		goto next_i;
	}
	catch (exception e)
	{
		return;
	}
}

int main()
{
	a = vector<int>(11);
	cin >> n;

	readi();
	fori();
	resi();

	cout << res << endl;

	return 0;
}

#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[20][20];
#define Fo(i,a,b) for(int i=a;i<b;i++)
int main()
{
    scanf("%d",&n);

        Fo(i,0,n)
        //for(int i=0;i<n;i++)
        {
            Fo(j,0,n)
            scanf("%d",&a[i][j]);
        }

        Fo(k,0,n)
        {

            Fo(i,0,n)
            {

                Fo(j,0,n)
                {

                    a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
                }
            }
        }
        int ans=0;
        Fo(i,0,n)
        {
            Fo(j,0,n)
            {
                ans=max(ans,a[i][j]);
            }

        }
        printf("%d\n",ans);

    return 0;
}

using namespace std;
#include<bits/stdc++.h>
#define open freopen("in.inp","r",stdin);freopen("in.out","w",stdout);
#define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define FOR(i,a,b) for(int i = a ,_b = (b); i <= _b ; i ++ )
#define FOD(i,a,b) for(int i = a ,_b = (b); i >= _b ; i -- )
#define sz size()
#define pb push_back
#define PI 2*acos(0)
#define DEB(X) cout << #X << " = " <<  X << endl ;
typedef long long ll ;
typedef pair<int,int> II ;
typedef pair<ll,ll> LL ;
const int INF = 1e9+7 ;
const int MOD = 1e9+7 ;
const int MAXN = 1e5+100 ;
const double eps = 1e-9 ;
int f[20][20] ;
int main(){

    #ifndef ONLINE_JUDGE
        open;
    #endif
    cout << setprecision(10) << fixed ;
    int n ;
    cin >> n  ;
    FOR(i , 1 , n){
        FOR(j , 1 , n){
            cin >> f[i][j] ;
        }
    }
    FOR(k , 1 , n){
        FOR(i , 1 , n){
            FOR(j , 1 , n){
                f[i][j] = min(f[i][j] , f[i][k] + f[k][j]) ;
            }
        }
    }
    int ans =  0 ;
    FOR(i , 1 , n){
        FOR(j , 1 , n) {
            ans = max(ans , f[i][j]) ;
        }
    }
    cout << ans;
    return 0;
}

//In the name of god

#include <bits/stdc++.h>

using namespace std;

const int Maxn = 100;;

int n, arr[Maxn][Maxn];
int res = 0;

void input()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> arr[i][j];
}

void output()
{
	cout << res << '\n';
}

void solver()
{
	f/**/or (int p = 0; p < 10000; ++p)
		f/**/or (int i = 0; i < n; ++i)
			fo/**/r (int j = 0; j < n; ++j)
				fo/**/r (int k = 0; k < n; ++k)
					arr[j][i] = arr[i][j] = min(arr[i][j], arr[i][k] + arr[k][j]);

	fo/**/r (int i = 0; i < n; ++i)
		fo/**/r (int j = 0; j < n; ++j)
			res = max(res, arr[i][j]);
}

int main()
{
	input();
	solver();
	output();

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <stack>
#include <set>
#include <algorithm>
#include <bitset>
#include <functional>
#include <ctime>
#include <cassert>
#include <valarray>
#include <unordered_map>

using namespace std;

const int N = 10;
int n, i, j, k, c, res = 0;
int dists[N][N];

void read_next()
{
	cin >> dists[i][j];
	++j == n ? 1 : read_next();
}

void read()
{
	j = 0;
	read_next();
	++i == n ? 1 : read();
}

void calc_next2()
{
	dists[i][j] = min(dists[i][j], dists[i][k] + dists[k][j]);
	++j == n ? 1 : calc_next2();
}

void calc_next1()
{
	j = 0;
	calc_next2();
	++i == n ? 1 : calc_next1();
}

void calc()
{
	i = 0;
	calc_next1();
	++k == n ? 1 : calc();
}

void relax1()
{
	res = max(res, dists[i][j]);
	++j == n ? 1 : relax1();
}

void relax()
{
	j = 0;
	relax1();
	++i == n ? 1 : relax();
}

void solve()
{
	cin >> n;
	i = 0;
	read();

	k = 0;
	calc();

	i = 0;
	relax();

	cout << res;
}

int main()
{

	solve();

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int dis[20][20];
int n;
int Floyd(int n)
{
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			ans=max(ans,dis[i][j]);
	return ans;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>dis[i][j];
	cout<<Floyd(n)<<"\n";
}

#include <cstdio>
#include <iostream>

using namespace std;

int n,f[11][11],ans;

int main()
{
	scanf("%d", &n);
	for (int i = 1 ; i <= n ; ++ i)
	{
		for (int j = 1 ; j <= n ; ++ j)
		{
			scanf("%d", &f[i][j]);
		}
	}
	for (int i = 1 ; i <= n ; ++ i)
	{
		for (int j = 1 ; j <= n ; ++ j)
		{
			for (int k = 1 ; k <= n ; ++ k)
			{
				f[i][j] = min(f[i][j],f[i][k] + f[j][k]);
			}
		}
	}
	for (int i = 1 ; i <= n ; ++ i)
	{
		for (int j = 1 ; j <= n ; ++ j)
		{
			if (i == j) continue;
			ans = max(ans,f[i][j]);
		}
	}
	printf("%d", ans);
	return 0;
}