#include <iostream>
#define nmax 1005
using namespace std;
int a[nmax][nmax],cifre[nmax];
int main()
{
int n,i,j,s=0,n1;
cin>>n;
n1=n;
while(n1>0)
{
cifre[++s]=n1%10;
n1/=10;
}
///de sub diag principala
for(i=1;i<=6;i++)
for(j=i+1;j<=6;j++)
a[j][i]=cifre[i];
///deasupra diag principale
for(i=1;i<=6;i++)
for(j=i+1;j<=6;j++)
a[i][j]=cifre[i];
for(i=1;i<=6;i++)
{
for(j=1;j<=6;j++)
cout<<a[i][j]<<" ";
cout<<"\n";
}
}