#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][4]=a[4][3]=a[3][2]=1;
for(i=1;i<=n;i++)
for(k=1;k<=n;k++)
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++)
printf("%d%c",a[i][j],j<n?' ':'\n');
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgaW50IGFbNV1bNV07CglpbnQgbj00LGksaixrOwoJZm9yKGk9MTtpPD1uO2krKykKCQlmb3Ioaj0xO2o8PW47aisrKQoJCQlhW2ldW2pdID0gaT09aiA/IDAgOiA5OwoJYVsxXVs0XT1hWzRdWzNdPWFbM11bMl09MTsKCWZvcihpPTE7aTw9bjtpKyspCgkJZm9yKGs9MTtrPD1uO2srKykKCQkJZm9yKGo9MTtqPD1uO2orKykKCQkJCWFbaV1bal0gPSBtaW4oYVtpXVtqXSwgYVtpXVtrXSArIGFba11bal0pOwoJZm9yKGk9MTtpPD1uO2krKykKCQlmb3Ioaj0xO2o8PW47aisrKQoJCQlwcmludGYoIiVkJWMiLGFbaV1bal0sajxuPycgJzonXG4nKTsKICAgIHJldHVybiAwOwp9