#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
int a[5][5];
int n=4,i,j,k;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
a[i][j] = i==j ? 0 : 9;
a[1][3]=a[3][4]=a[4][2]=1;
for(j=1;j<=n;j++)
for(k=1;k<=n;k++)
for(i=1;i<=n;i++)
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++)
printf("%d%c",a[i][j],j<n?' ':'\n');
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgaW50IGFbNV1bNV07CglpbnQgbj00LGksaixrOwoJZm9yKGk9MTtpPD1uO2krKykKCQlmb3Ioaj0xO2o8PW47aisrKQoJCQlhW2ldW2pdID0gaT09aiA/IDAgOiA5OwoJYVsxXVszXT1hWzNdWzRdPWFbNF1bMl09MTsKCWZvcihqPTE7ajw9bjtqKyspCgkJZm9yKGs9MTtrPD1uO2srKykKICAgICAgICAgICAgZm9yKGk9MTtpPD1uO2krKykKCQkJCWFbaV1bal0gPSBtaW4oYVtpXVtqXSwgYVtpXVtrXSArIGFba11bal0pOwoJZm9yKGk9MTtpPD1uO2krKykKCQlmb3Ioaj0xO2o8PW47aisrKQoJCQlwcmludGYoIiVkJWMiLGFbaV1bal0sajxuPycgJzonXG4nKTsKICAgIHJldHVybiAwOwp9