import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[][] times = new int[6][6];
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
times[i][j] = sc.nextInt();
if (times[i][j] == -1) {
times[i][j] = Integer.MAX_VALUE;
}
}
}
int[] dist = distence(times);
for (int i = 1; i < 6; i++) {
System.out.println(dist[i]);
}
}
public static int[] distence(int[][] times) {
int maxTime = Integer.MAX_VALUE;
int N = 6;
int[] dist = new int[N];
boolean[] isVisited = new boolean[N];
for (int i = 0; i < N; i++) {
dist[i] = times[0][i];
}
isVisited[0] = true;
for (int i = 0; i < N; i++) {
int min = maxTime;
int k = 0;
for (int j = 0; j < N; j++) {
if (!isVisited[j] && dist[j] < min) {
min = dist[j];
k = j;
}
}
isVisited[k] = true;
for (int j = 0; j < N; j++) {
if (!isVisited[j] && times[k][j] != maxTime) {
if (dist[j] >= times[k][j] + dist[k]) {
dist[j] = times[k][j] + dist[k];
}
}
}
}
return dist;
}
}
ac了,按回忆写的,有些可能有问题,但是大概思路就是这个