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.

Input

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

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

Examples

Input

3
0 1 1
1 0 4
1 4 0


Output

2


Input

4
0 1 2 3
1 0 4 5
2 4 0 6
3 5 6 0


Output

5

Note

You're running short of keywords, so you can't use some of them:
    
    
    define  
    do  
    for  
    foreach  
    while  
    repeat  
    until  
    if  
    then  
    else  
    elif  
    elsif  
    elseif  
    case  
    switch  
    
6
0 41 48 86 94 14
41 0 1 30 59 39
48 1 0 9 31 49
86 30 9 0 48 30
94 59 31 48 0 33
14 39 49 30 33 0
 6
0 92 9 24 50 94
92 0 70 73 57 87
9 70 0 31 14 100
24 73 31 0 66 25
50 57 14 66 0 81
94 87 100 25 81 0
 3
0 86 45
86 0 54
45 54 0
 6
0 41 81 77 80 79
41 0 64 36 15 77
81 64 0 36 89 40
77 36 36 0 59 70
80 15 89 59 0 90
79 77 40 70 90 0
 4
0 59 70 47
59 0 63 78
70 63 0 93
47 78 93 0
 3
0 1 1
1 0 1
1 1 0
 9
0 89 47 24 63 68 12 27 61
89 0 48 62 96 82 74 99 47
47 48 0 72 63 47 25 95 72
24 62 72 0 54 93 10 95 88
63 96 63 54 0 19 6 18 3
68 82 47 93 19 0 68 98 30
12 74 25 10 6 68 0 21 88
27 99 95 95 18 98 21 0 3
61 47 72 88 3 30 88 3 0
 8
0 12 11 41 75 73 22 1
12 0 84 11 48 5 68 87
11 84 0 85 87 64 14 5
41 11 85 0 75 13 36 11
75 48 87 75 0 41 15 14
73 5 64 13 41 0 63 50
22 68 14 36 15 63 0 90
1 87 5 11 14 50 90 0
 10
0 62 27 62 65 11 82 74 46 40
62 0 8 11 15 28 83 3 14 26
27 8 0 21 14 12 69 52 26 41
62 11 21 0 34 35 9 71 100 15
65 15 14 34 0 95 13 69 20 65
11 28 12 35 95 0 35 19 57 40
82 83 69 9 13 35 0 21 97 12
74 3 52 71 69 19 21 0 82 62
46 14 26 100 20 57 97 82 0 96
40 26 41 15 65 40 12 62 96 0
 10
0 1 1 1 1 1 1 1 1 100
1 0 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1
1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 1 0 1
100 1 1 1 1 1 1 1 1 0
 8
0 6 39 40 67 19 77 93
6 0 25 9 67 48 26 65
39 25 0 72 62 45 26 88
40 9 72 0 69 19 88 4
67 67 62 69 0 2 51 1
19 48 45 19 2 0 60 14
77 26 26 88 51 60 0 1
93 65 88 4 1 14 1 0
 9
0 29 71 8 12 39 50 26 21
29 0 76 87 29 91 99 94 57
71 76 0 74 12 38 24 46 49
8 87 74 0 62 22 23 44 25
12 29 12 62 0 97 38 47 39
39 91 38 22 97 0 69 62 50
50 99 24 23 38 69 0 4 75
26 94 46 44 47 62 4 0 100
21 57 49 25 39 50 75 100 0
 3
0 99 73
99 0 8
73 8 0
 5
0 92 34 49 44
92 0 5 54 57
34 5 0 8 24
49 54 8 0 76
44 57 24 76 0
 8
0 24 87 58 2 2 69 62
24 0 58 43 98 29 18 33
87 58 0 71 43 37 4 31
58 43 71 0 30 77 19 46
2 98 43 30 0 48 18 64
2 29 37 77 48 0 57 77
69 18 4 19 18 57 0 52
62 33 31 46 64 77 52 0
 6
0 74 60 92 18 86
74 0 96 55 30 81
60 96 0 6 28 30
92 55 6 0 5 89
18 30 28 5 0 11
86 81 30 89 11 0
 10
0 1 100 100 100 100 100 100 100 100
1 0 1 100 100 100 100 100 100 100
100 1 0 1 100 100 100 100 100 100
100 100 1 0 1 100 100 100 100 100
100 100 100 1 0 1 100 100 100 100
100 100 100 100 1 0 1 100 100 100
100 100 100 100 100 1 0 1 100 100
100 100 100 100 100 100 1 0 1 100
100 100 100 100 100 100 100 1 0 1
100 100 100 100 100 100 100 100 1 0
 10
0 65 97 17 34 86 3 22 92 98
65 0 71 14 76 35 22 69 82 89
97 71 0 58 6 62 45 100 76 14
17 14 58 0 100 42 83 3 1 21
34 76 6 100 0 15 90 77 69 32
86 35 62 42 15 0 3 96 40 6
3 22 45 83 90 3 0 65 28 87
22 69 100 3 77 96 65 0 70 73
92 82 76 1 69 40 28 70 0 39
98 89 14 21 32 6 87 73 39 0
 9
0 83 88 2 30 55 89 28 96
83 0 46 27 71 81 81 37 86
88 46 0 11 28 55 7 71 31
2 27 11 0 27 65 24 94 23
30 71 28 27 0 16 57 18 88
55 81 55 65 16 0 68 92 71
89 81 7 24 57 68 0 29 70
28 37 71 94 18 92 29 0 21
96 86 31 23 88 71 70 21 0
 6
0 45 91 95 34 82
45 0 73 77 9 38
91 73 0 61 74 71
95 77 61 0 93 17
34 9 74 93 0 73
82 38 71 17 73 0
 7
0 50 95 10 100 75 71
50 0 53 70 70 26 91
95 53 0 16 33 90 98
10 70 16 0 43 48 87
100 70 33 43 0 63 34
75 26 90 48 63 0 17
71 91 98 87 34 17 0
 3
0 35 50
35 0 28
50 28 0
 10
0 16 67 7 82 44 25 13 25 42
16 0 24 37 63 20 19 87 55 99
67 24 0 81 19 71 35 6 20 91
7 37 81 0 82 89 34 80 7 32
82 63 19 82 0 42 66 96 42 99
44 20 71 89 42 0 65 94 24 45
25 19 35 34 66 65 0 97 100 22
13 87 6 80 96 94 97 0 10 58
25 55 20 7 42 24 100 10 0 29
42 99 91 32 99 45 22 58 29 0
 8
0 73 45 10 61 98 24 80
73 0 47 29 65 96 46 36
45 47 0 63 48 19 57 99
10 29 63 0 11 13 79 84
61 65 48 11 0 60 71 27
98 96 19 13 60 0 41 44
24 46 57 79 71 41 0 13
80 36 99 84 27 44 13 0
 7
0 41 2 49 25 23 43
41 0 21 3 1 35 74
2 21 0 63 45 6 55
49 3 63 0 90 92 9
25 1 45 90 0 11 11
23 35 6 92 11 0 77
43 74 55 9 11 77 0
 8
0 25 9 7 32 10 42 77
25 0 18 90 53 83 1 50
9 18 0 21 12 83 68 79
7 90 21 0 97 67 51 16
32 53 12 97 0 83 29 6
10 83 83 67 83 0 50 69
42 1 68 51 29 50 0 70
77 50 79 16 6 69 70 0
 10
0 27 56 32 37 99 71 93 98 50
27 0 21 57 7 77 88 40 90 81
56 21 0 20 45 98 82 69 15 23
32 57 20 0 15 74 72 95 49 56
37 7 45 15 0 25 17 60 7 80
99 77 98 74 25 0 80 62 31 63
71 88 82 72 17 80 0 38 43 9
93 40 69 95 60 62 38 0 7 53
98 90 15 49 7 31 43 7 0 48
50 81 23 56 80 63 9 53 48 0
 6
0 67 17 21 20 86
67 0 32 80 24 36
17 32 0 20 37 90
21 80 20 0 58 98
20 24 37 58 0 22
86 36 90 98 22 0
 9
0 76 66 78 46 55 92 18 81
76 0 99 62 23 53 45 41 10
66 99 0 18 3 37 34 26 91
78 62 18 0 98 36 59 5 27
46 23 3 98 0 79 92 9 39
55 53 37 36 79 0 89 60 25
92 45 34 59 92 89 0 26 94
18 41 26 5 9 60 26 0 19
81 10 91 27 39 25 94 19 0
 3
0 72 17
72 0 8
17 8 0
 9
0 62 15 44 79 3 30 46 49
62 0 79 42 86 71 78 68 98
15 79 0 2 34 34 97 71 76
44 42 2 0 11 76 4 64 25
79 86 34 11 0 45 48 75 81
3 71 34 76 45 0 73 5 40
30 78 97 4 48 73 0 50 16
46 68 71 64 75 5 50 0 14
49 98 76 25 81 40 16 14 0
 7
0 67 86 9 33 16 99
67 0 77 68 97 59 33
86 77 0 37 11 83 99
9 68 37 0 51 27 70
33 97 11 51 0 32 91
16 59 83 27 32 0 71
99 33 99 70 91 71 0
 5
0 1 6 73 37
1 0 4 29 76
6 4 0 74 77
73 29 74 0 45
37 76 77 45 0
 6
0 44 27 40 72 96
44 0 87 1 83 45
27 87 0 43 81 64
40 1 43 0 89 90
72 83 81 89 0 37
96 45 64 90 37 0
 4
0 98 25 16
98 0 89 1
25 89 0 2
16 1 2 0

47 87 86 90 93 1 69 37 46 2 31 59 81 44 57 48 9 45 70 95 71 50 64 63 30 36 59 63 67 25 67 99 45 86 18
#include <bits/stdc++.h>
using namespace std;
int a[11][11];
template <class T>
bool go(int k, const T& func) {
  return k ? go(k - 1, func), func(k - 1), 0 : 0;
}
int main() {
  int n;
  cin >> n;
  go(n, [&](int i) { go(n, [&](int j) { cin >> a[i][j]; }); });
  int ans = 0;
  go(n, [&](int k) {
    go(n, [&](int i) {
      go(n, [&](int j) { a[i][j] = min(a[i][j], a[i][k] + a[k][j]); });
    });
  });
  go(n, [&](int i) { go(n, [&](int j) { ans = max(ans, a[i][j]); }); });
  cout << ans << endl;
  return 0;
}
