semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
void Find( int matrix[][9], int n );
int main()
{

	int matrix[ 9 ][ 9 ];
	int i, j;
	int m, n;
	for ( i =0; i < 9; i++ )
	{
		for ( j =0; j < 9; j++ )
			matrix[ i ][ j ] = 0;
	}


	cin >> m >> n;
	
	matrix[ 4 ][ 4 ] = m;
	Find( matrix, n );


	for ( i = 0; i < 9; i++ )
	{
		cout << matrix[ i ][ 0 ];
		for ( j = 1; j < 9; j++ )
		{
			cout <<" " << matrix[ i ][ j ];
		}
		cout << endl;
	}
}
	

void Find( int matrix[][9], int n)
{
	int i, j;
	int temp[9][9];
	memset( temp,0,sizeof(temp));
	if ( n == 0 )
		return;
	for ( i = 1; i < 8; i++ )
	{
		for ( j = 1; j < 8; j++ )
		if ( matrix[ i ][ j ] != 0 )
		{
			temp[ i ][ j ] =  2 * matrix[ i ][ j ]+temp[ i ][ j ]; 

			temp[ i + 1 ][ j ] =  matrix[ i ][ j ] + temp[ i + 1 ][ j ]; 

			temp[ i - 1 ][ j ] = matrix[ i ][ j ] + temp[ i - 1 ][ j ]; 

			temp[ i ][ j + 1 ] =  matrix[ i ][ j ] + temp[ i ][ j + 1 ]; 

			temp[ i ][ j - 1 ] =  matrix[ i ][ j ] + temp[ i ][ j - 1 ]; 
			temp[ i + 1 ][ j - 1 ] =  matrix[ i  ][ j  ] + temp[ i + 1 ][ j - 1 ]; 
			temp[ i + 1 ][ j + 1 ] = matrix[ i  ][ j ] + temp[ i + 1 ][ j + 1 ]; 
			temp[ i - 1 ][ j - 1 ] = matrix[ i ][ j ] + temp[ i - 1 ][ j - 1 ]; 
			temp[ i - 1 ][ j + 1 ] = matrix[ i ][ j ] + temp[ i - 1 ][ j + 1 ]; 
		}
	}

	for ( i = 0; i < 9; i++ )
		for ( j = 0; j < 9; j++ )
			matrix[ i ][ j ] = temp[ i ][ j ];
	Find( matrix, n - 1 );
}
int main ()
{
	int a[11][11]={0},b[11][11];
	int m,n,i,j,k;
	cin >> m >> n;
	a[5][5]=m;
	for (k=0;k<n;k++)
	{
		for (i=0;i<11;i++)
			for (j=0;j<11;j++)
				b[i][j]=a[i][j];
	    for (i=1;i<11;i++)
		{
	    	for (j=1;j<11;j++)
			{
		    	a[i][j]=b[i][j]*2+b[i][j-1]+b[i][j+1]+b[i+1][j]+
				b[i-1][j]+b[i+1][j+1]+b[i+1][j-1]+b[i-1][j+1]+b[i-1][j-1];
			}
		}
	}
	for (i=1;i<10;i++)
	{
		for (j=1;j<10;j++)
		{
			if(j!=1)
			    cout << " " << a[i][j] ;
			else
				cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}
int main()
{
	int a[9][9],b[9][9],i,j,k,m,n;
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			a[i][j]=0;
			b[i][j]=0;
		}
	}
	scanf("%d %d",&m,&n);
	a[4][4]=m;
	b[4][4]=m;
	for(k=0;k<n;k++)
	{
		for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
				if(a[i][j]!=0)
				{
					b[i][j]+=a[i][j];
					b[i][j-1]+=a[i][j];
					b[i][j+1]+=a[i][j];
					b[i-1][j]+=a[i][j];
					b[i+1][j]+=a[i][j];
					b[i-1][j-1]+=a[i][j];
					b[i-1][j+1]+=a[i][j];
					b[i+1][j-1]+=a[i][j];
					b[i+1][j+1]+=a[i][j]; 
				}
			}
		}
	  for(i=0;i<9;i++)
		  for(j=0;j<9;j++)
			a[i][j]=b[i][j];
	}
	for(i=0;i<9;i++)
	{
		for(j=0;j<8;j++)
		{
			printf("%d ",b[i][j]);
			
		}
     	printf("%d",b[i][8]);
			
	
		printf("\n");
	}
	
	return 0;
}
void step(int a[N][N])
{
	int b[N][N]={0};
	int i,j,k,l;
	for(i=0;i<N;i++)
	{
		for(j=0;j<N;j++)
		{
			b[i][j]=a[i][j];
			a[i][j]=0;
		}
	}
	for(i=1;i<N-1;i++)
	{
		for(j=1;j<N;j++)
		{
			if(b[i][j]>0)
			{
				for(k=i-1;k<=i+1;k++)
				{
					for(l=j-1;l<=j+1;l++)
					{
						a[k][l]+=b[i][j];
					}
				}
				a[i][j]+=b[i][j];
			}
		}
	}
}
int main()
{
	int a[N][N]={0},m,n,t,p;
    scanf("%d %d",&m,&n);
	a[N/2][N/2]=m;
	for(t=0;t<n;t++)
	{
		step(a);
	}
	for(t=0;t<N;t++)
	{
		printf("%d",a[t][0]);
		for(p=1;p<N;p++)
		{
			printf(" %d",a[t][p]);
		}
		printf("\n");

	}
	return 0;
}
//********************************
//* ??? ????????                      
//* ?????                   *
//********************************
int a[9][9]={0};//??????????
int b[9][9]={0};//??????????

void f(int n)
{
	int i,j;
	if(n>0)
	{
	for(i=1;i<=7;i++)
		for(j=1;j<=7;j++)
		{
			if(a[i][j]>0)
			{
				b[i][j]+=2*a[i][j];
				b[i][j+1]+=a[i][j];
				b[i][j-1]+=a[i][j];
				b[i+1][j]+=a[i][j];
				b[i-1][j]+=a[i][j];
				b[i-1][j+1]+=a[i][j];
				b[i+1][j-1]+=a[i][j];
				b[i+1][j+1]+=a[i][j];
				b[i-1][j-1]+=a[i][j];
			}
		}
		for(i=0;i<9;i++)
			for(j=0;j<9;j++)
			{
				a[i][j]=b[i][j];
				b[i][j]=0;
			}
			f(n-1);
	}
	else if(n==0)
	{
		for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
				if(j==0)
					cout<<a[i][j];
				else
					cout<<" "<<a[i][j];
			}
			cout<<endl;
		}
	}
}
int main()
{
	int m,day;
	cin>>m>>day;
	a[4][4]=m;
	f(day);
	return 0;
}
//**************************************
//* ????????????          ** 
//* ?????? 1300012948           ** 
//* ???2013.12.5                   ** 
//**************************************
int a[11][11], b[11][11], day = 0;
int main()
{
    int m, n;
    cin >> m >> n; // ????????????? 
    void result(int p, int q); // ???? 
    for(int i = 0; i <= 11; i++) // ????????????????????????0 
    {
            for(int j = 0; j <= 11; j++)
            {
                    a[i][j] = 0;
            }
    }
    a[5][5] = m; // ????????????????????? 
    result(m, n); // ???? 
    return 0;
}

void result(int p, int q)
{
     if(day < q) // ??????????????? 
     {
            for(int r = 1; r<= 9; r++) // ?????????day???????????b?? 
            {
                  for(int s = 1; s <= 9; s++)
                  {
                        b[r][s] = a[r][s]; // ??????r, s???a?????b????? 
                        for(int temp1 = r - 1; temp1 <= r + 1; temp1++) // ?????r, s????????????????????????????????
                        {
                                for(int temp2 = s - 1; temp2 <= s + 1; temp2++)
                                {
                                        b[r][s] += a[temp1][temp2];
                                }
                        }
                  }
            }
            day++; // ???1 
            for(int i = 1; i <= 9; i++) // ???b???????a 
            {
                    for(int j = 1; j <= 9; j++)
                    {
                            a[i][j] = b[i][j];
                    }
            }
            result(p, q); // ???????day + 1???????? 
     }
     else // ????????????????????? 
     {
         for(int i = 1; i <= 9; i++)
         {
                 for(int j = 1; j <= 9; j++)
                 {
                         if(j < 9)
                         {
                              cout << a[i][j] << " ";
                         }
                         else
                         {
                             cout << a[i][j] << endl;
                         }
                 }
         }
     }
}
int main()
{
	int m,n,i,j,k,t;
	scanf("%d%d",&m,&n);
	int a[9][9]={0},b[9][9]={0};
	a[4][4]=m;
	for (i=1;i<=n;i++)
	{
		for(j=0;j<9;j++)
		{
			for(k=0;k<9;k++)
			{
				if(a[j][k]==0)continue;
				else
				{
					t=a[j][k];
					b[j][k]+=2*t;
					b[j-1][k-1]+=t;
					b[j-1][k]+=t;
					b[j-1][k+1]+=t;
					b[j][k-1]+=t;
					b[j][k+1]+=t;
					b[j+1][k-1]+=t;
					b[j+1][k]+=t;
					b[j+1][k+1]+=t;
				}
			}
		}
		for(j=0;j<9;j++)
		{
			for(k=0;k<9;k++)
			{
				a[j][k]=b[j][k];
				b[j][k]=0;
			}
		}
		
	}
	for(j=0;j<9;j++)
		{
			for(k=0;k<8;k++)
			{
				printf("%d ",a[j][k]);
			}
			printf("%d\n",a[j][8]);
	}
	return 0;
}
int num[11][11];
int num1[11][11];
int increase(int a,int time)
{
    if(a==time)  return 1;
    else
    {
        memset(num1,0,sizeof(num1));
        for(int i=0;i<11;i++)  
        {
                num[i][0]=num[i][10]=num[0][i]=num[i][10]=0;
        }
        for(int i=1;i<10;i++)
        {
                for(int j=1;j<10;j++)
                {
                        if(num[i][j]!=0)
                        {
                                        num1[i][j]=num1[i][j]+2*num[i][j];
                                        num1[i][j-1]=num1[i][j-1]+num[i][j];
                                        num1[i-1][j]=num1[i-1][j]+num[i][j];
                                        num1[i+1][j]=num1[i+1][j]+num[i][j];
                                        num1[i][j+1]=num1[i][j+1]+num[i][j];
                                        num1[i-1][j-1]=num1[i-1][j-1]+num[i][j];
                                        num1[i+1][j-1]=num1[i+1][j-1]+num[i][j];
                                        num1[i-1][j+1]=num1[i-1][j+1]+num[i][j];
                                        num1[i+1][j+1]=num1[i+1][j+1]+num[i][j];
                        }
                }
        }
        for(int i=0;i<11;i++)
        {
                for(int j=0;j<11;j++)
                {
                        num[i][j]=num1[i][j];
                }
        }
        return increase(a+1,time);
    }
}
int main()
{
    int n,t;
    cin>>n>>t;
    memset(num,0,sizeof(num));
    memset(num1,0,sizeof(num1));
    num[5][5]=n;
    num[5][5]=n;
    increase(0,t);
    for(int i=1;i<10;i++)
    {
            for(int j=1;j<9;j++)
            {
                    cout<<num1[i][j]<<' ';
            }
            cout<<num1[i][9]<<endl;
    }
    return 0;
}
int a[9][9];
int b[9][9];

int main()
{
	int m, n;
	cin >> m >> n;
	memset(a,0,sizeof(a));
	a[4][4]=m;
	int i, x, y;
	for (i = 0; i !=n;i++)
	{
		memset(b,0,sizeof(b));
		for (x=1;x!=8;x++)
			for(y=1;y!=8;y++)
			{
				b[x][y]+=2*a[x][y];
				b[x-1][y-1]+=a[x][y];b[x-1][y]+=a[x][y];b[x-1][y+1]+=a[x][y];b[x][y-1]+=a[x][y];b[x][y+1]+=a[x][y];b[x+1][y-1]+=a[x][y];b[x+1][y]+=a[x][y];b[x+1][y+1]+=a[x][y];
			}
		memcpy(a,b,sizeof(a));
	}
	for(x=0;x!=9;x++)
	{
		for(y=0;y!=9;y++)
		{
			if(y==0)
				cout << a[x][y];
			else
				cout << ' ' << a[x][y];
		}
		cout << endl;
	}
	return 0;
}
int main()
{
	int n,m,a[9][9],i,j,z,b,c,d[9][9];
	scanf("%d%d",&m,&n);
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			a[i][j]=0;
			d[i][j]=0;
		}
	}
	a[4][4]=m;
	d[4][4]=m;

	for(z=1;z<=n;z++)
	{
		for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
				if(a[i][j]!=0){
					for(b=i-1;b<=i+1;b++)
					{
						for(c=j-1;c<=j+1;c++)
						{
							d[b][c]+=a[i][j];
						}
					}
				}
			}
		}
		for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
				a[i][j]=d[i][j];
			}
		}
	}
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			if(j==8){
				printf("%d\n",d[i][j]);
			}else{
				printf("%d ",d[i][j]);
			}
		}
	}
	return 0;
}
main()
{
 int a[10][10]={0},b[10][10]={0};
 int i,j,k,m,n;
 scanf("%d%d",&m,&n);
 a[5][5]=m;
 for(k=0;k<n;k++)
 {
 for(i=1;i<=9;i++)
 for(j=1;j<=9;j++)
 {
  if(a[i][j]!=0) 
  {
   int s=2*a[i][j];int t=a[i][j];
   b[i][j]+=s;
   b[i][j+1]+=t;b[i][j-1]+=t;b[i+1][j+1]+=t;b[i+1][j-1]+=t;b[i+1][j]+=t;b[i-1][j]+=t;b[i-1][j+1]+=t;b[i-1][j-1]+=t;           
                }               
                  }               
   for(int p=1;p<=9;p++)
   {
    for(int q=1;q<=9;q++)
    {
     a[p][q]=b[p][q];
     b[p][q]=0;       
            }       
           }              
                 }
                 for(i=1;i<=9;i++)
                 for(j=1;j<=9;j++)
                 {printf("%d",a[i][j]);
                 if(j==9)
                 {printf("\n");}
                 else{printf(" ");}}   
 
      }
//********************************
//*???2.cpp   **
//*???????????   **
//*?????? 1300012838 **
//*???2013.12.4  **
//********************************

int m;

int day(int x, int y, int n)
{
    if (x == 0 || x == 10 || y == 0 || y == 10)
        return 0;
    else if (x == 5 && y == 5 && n == 0)
        return m;
    else if (n == 0)
        return 0;
    else
        return day(x, y, n-1) * 2 + day(x-1, y, n-1) + day(x+1, y, n-1) + 
               day(x, y-1, n-1) + day(x, y+1, n-1) + day(x-1, y-1, n-1) + 
               day(x-1, y+1, n-1) + day(x+1, y-1, n-1) + day(x+1, y+1, n-1);
} 

int main()
{
    int n;
    cin >> m >> n;
    for (int i = 1; i <= 9; i++)
    {
        cout << day(i, 1, n);
        for (int j = 2; j <= 9; j++)
            cout << " " << day(i, j, n);
        cout << endl;
    }

    return 0;
}
int num[9][9] = {0}, flag[9][9] = {0};
int m;
int main()
{
    int n;
    cin >> m >> n;
    void fun ( int );
	num[4][4] = m;
    fun ( n );
    return 0;
}
void fun ( int n )
{
     if ( n == 0 )
     {
          int i, j;
          for ( i = 0; i < 9; i++ )
          {
              cout << num[i][0];
              for ( j = 1; j < 9; j++ )
              {
                  cout << " " << num[i][j];
              }
              cout << endl;
          }
     }
     else
     {
         int i, j;
         for ( i = 0; i < 9; i++ )
         {
             for ( j = 0; j < 9; j++ )
             {
                 if ( num[i][j] != 0 )
                 {
                      flag[i][j - 1] += num[i][j];
                      flag[i][j + 1] += num[i][j];
                      flag[i + 1][j] += num[i][j];
                      flag[i - 1][j] += num[i][j];
					  flag[i + 1][j - 1] += num[i][j];
					  flag[i - 1][j - 1] += num[i][j];
					  flag[i + 1][j + 1] += num[i][j];
					  flag[i - 1][j + 1] += num[i][j];
					  flag[i][j] += num[i][j];
                 }
             }
         }
         for ( i = 0; i < 9; i++ )
         {
             for ( j = 0; j < 9; j++ )
             {
                 num[i][j] += flag[i][j];
             }
         }
         for ( i = 0; i < 9; i++ )
         {
             for ( j = 0; j < 9; j++ )
             {
                 flag[i][j] = 0;
             }
         }
         fun ( n - 1 );
     }
}
int main()
{
	const int n = 9;
    int init, days, m[2][n+2][n+2] = {0};
    cin >> init >> days;
    m[0][5][5] = init;
    for (int k = 0; k < days; k++) {
		for (int i = 0; i <= n + 1; i++)
			for (int j = 0; j <= n + 1; j++)
				m[1-k%2][i][j] = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				if (m[k%2][i][j]) {
					m[1-k%2][i+1][j+1] += m[k%2][i][j];
					m[1-k%2][i+1][j] += m[k%2][i][j];
					m[1-k%2][i+1][j-1] += m[k%2][i][j];
					m[1-k%2][i][j+1] += m[k%2][i][j];
					m[1-k%2][i][j-1] += m[k%2][i][j];
					m[1-k%2][i-1][j+1] += m[k%2][i][j];
					m[1-k%2][i-1][j] += m[k%2][i][j];
					m[1-k%2][i-1][j-1] += m[k%2][i][j];
					m[1-k%2][i][j] += m[k%2][i][j] * 2;
				}
    }
    for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			cout << m[days%2][i][j];
			if (j == n) cout << endl;
			else cout << ' ';
		}
    return 0;
}
int main()
{
   int num[9][9];
   int next[9][9];
   int m,n,i,j,t;
   int k,h;
   cin>>m>>n;
   
   for(i=0;i<9;i++)
      for(j=0;j<9;j++)
         {num[i][j]=0;
          next[i][j]=0;}
   num[4][4]=m;

   for(t=n;t>=1;t--)
     {for(i=0;i<9;i++)
        for(j=0;j<9;j++)
           if(num[i][j]!=0)
             {next[i][j]+=2*num[i][j];
              next[i-1][j]+=num[i][j];   
              next[i+1][j]+=num[i][j];
              next[i][j-1]+=num[i][j];
              next[i][j+1]+=num[i][j];
              next[i-1][j-1]+=num[i][j];
              next[i-1][j+1]+=num[i][j];
              next[i+1][j-1]+=num[i][j];
              next[i+1][j+1]+=num[i][j];
             }
      for(i=0;i<9;i++)
         for(j=0;j<9;j++)
              {num[i][j]=next[i][j];
               next[i][j]=0;}
     }
   for(i=0;i<9;i++)
       {for(j=0;j<8;j++)
           cout<<num[i][j]<<" ";
        cout<<num[i][j]<<endl;}

   return 0;
}
int main()
{
	int i,j,k,a[5][11][11]={0},sum,days;
	scanf("%d %d",&sum,&days);
    a[0][5][5]=sum;
	for(i=1;i<=days;i++)
	{
		for(j=1;j<11;j++)
		{
			for(k=1;k<11;k++)
			{
				a[i][j][k]=a[i-1][j][k]*2+a[i-1][j-1][k]+a[i-1][j+1][k]+a[i-1][j][k-1]+a[i-1][j][k+1]+a[i-1][j-1][k-1]+a[i-1][j-1][k+1]+a[i-1][j+1][k-1]+a[i-1][j+1][k+1];
			}
		}
	}
	for(j=1;j<10;j++)
	{
		for(k=1;k<9;k++)
		{
			printf("%d ",a[days][j][k]);
		}
		printf("%d",a[days][j][k]);
		printf("\n");
	}
	return 0;
}
int f(int x,int y,int n,int m)
{
    if (n>0) {
    //int i,j;
    //f(x,y,n)=0;
    //for (i=x-1;i<=x+1;i++)
    //for (j=y-1;j<=y+1;j++)
    //f(x,y,n)=f(x,y,n)+f(i,j,n-1);
    //return f(x,y,n)+f(x,y,n-1);}
    return (f(x-1,y-1,n-1,m)+f(x-1,y,n-1,m)+f(x-1,y+1,n-1,m)+f(x,y-1,n-1,m)+2*f(x,y,n-1,m)+f(x,y+1,n-1,m)+f(x+1,y-1,n-1,m)+f(x+1,y,n-1,m)+f(x+1,y+1,n-1,m));}
    else if (x==5&&y==5)
    return m;
    else
    return 0;
}
main()
{
      int i,j,m,n;
      scanf("%d %d",&m,&n);
      int a[12][12][n];
      //a[5][5][0]=m;
      for (i=1;i<=9;i++)
      {
          for (j=1;j<=9;j++)
          {
              a[i][j][n]=f(i,j,n,m);
          }
      }
      for (i=1;i<=9;i++)
      {
          for (j=1;j<=8;j++)
          {
              printf("%d ",a[i][j][n]);
          }
          printf("%d\n",a[i][9][n]);
      }
      getchar();
      getchar();
      getchar();
}
int main()
{
    int m,n;
    int a[11][11],add[11][11];
    for (int i=0;i<11;i++)
    {
        for (int j=0;j<11;j++)
        {
            a[i][j]=0;
            add[i][j]=0;
        }
    }
    scanf ("%d %d",&m,&n);
    a[5][5]=m;
    for (int i=0;i<n;i++)
    {
        for (int x=1;x<10;x++)
        {
            for (int y=1;y<10;y++)
            add[x][y]=a[x][y]+a[x-1][y]+a[x][y-1]+a[x-1][y-1]+a[x-1][y+1]+a[x][y+1]+a[x+1][y+1]+a[x+1][y]+a[x+1][y-1];
        }
        for (int x=1;x<10;x++)
        {
            for (int y=1;y<10;y++)
            a[x][y]=a[x][y]+add[x][y];
        }
    }
    for (int i=1;i<10;i++)
    {
        for (int j=1;j<10;j++)
        {
            if (j==1) printf ("%d",a[i][j]);
            else printf (" %d",a[i][j]);
        }
        printf ("\n");
    }
    return 0;
}
main()
{
     int  a[L][L],b[L][L];
     int m,n,d,i,j,x,y;
     scanf("%d %d",&m,&n);
     memset(a,0,sizeof(a));
     a[4][4]=m;
     for(d=1;d<=n;d++)
     {
              memset(b,0,sizeof(b));        
              for(i=1;i<L-1;i++)
              {
                       for(j=1;j<L-1;j++)
                       {
                               b[i][j]+=a[i][j];
                               for(x=-1;x<=1;x++)
                               {
                                       for(y=-1;y<=1;y++)
                                       b[i+y][j+x]=b[i+y][j+x]+a[i][j];          
                               }
                       }         
              }
              memcpy(a,b,sizeof(a));        
     }
     for(i=0;i<L;i++)
     {
              for(j=0;j<L-1;j++)
              printf("%d ",a[i][j]);
              printf("%d\n",a[i][8]);        
     }
     getchar();
     getchar();
     getchar();
     getchar();
}
int main()
{
	int board[11][11][2]={0},i,j,k;
	int m,n;//m???????????n???????
	cin>>m>>n;
	board[5][5][0]=m;

	for(k=1;k<=n;k++){
		for(i=1;i<=9;i++){
			for(j=1;j<=9;j++)
			{
			    board[i][j][1]=board[i][j][0]*2+board[i-1][j-1][0]+board[i-1][j][0]+board[i-1][j+1][0]+board[i][j-1][0]+board[i][j+1][0]+board[i+1][j-1][0]+board[i+1][j][0]+board[i+1][j+1][0];
			}}
		for(i=1;i<=9;i++){
			for(j=1;j<=9;j++){
			board[i][j][0]=board[i][j][1];
			}}}

	    for(i=1;i<=9;i++)
		{
			cout<<board[i][1][1];
			for(j=2;j<=9;j++)
			{
				cout<<' '<<board[i][j][1];
			}
		    cout<<endl;
		}
	return 0;}
int main()
{
	int m,n,i,j,k,x,y;
	scanf("%d %d",&m,&n);
	int u[10][10]={0};
	int q[10][10]={0};
	u[4][4]=m;
	q[4][4]=m;
	for(k=1;k<=n;k++){
	for(i=0;i<9;i++){
		for(j=0;j<9;j++){
			if(q[i][j]!=0)
			{
				u[i][j]+=q[i][j];
				u[i-1][j-1]+=q[i][j];
				u[i-1][j]+=q[i][j];
				u[i-1][j+1]+=q[i][j];
				u[i][j-1]+=q[i][j];
				u[i][j+1]+=q[i][j];
				u[i+1][j-1]+=q[i][j];
				u[i+1][j]+=q[i][j];
				u[i+1][j+1]+=q[i][j];
			}
		}
	}
	for(x=0;x<9;x++){
				for(y=0;y<9;y++){
					q[x][y]=u[x][y];
				}
			}
	}
	for(i=0;i<9;i++){
		for(j=0;j<9;j++){
			if(j==8)
			{
				printf("%d\n",u[i][j]);
			}
			else
			{
			printf("%d ",u[i][j]);
			}
		}
	}
	return 0;
}
int main()
{
	int a[MAX][MAX] = { 0 };
	int b[MAX][MAX] = { 0 };
	int m, n;
	cin >> m >> n;
	a[MAX / 2][MAX / 2] = m;
	for (int k = 0; k < n; k++)
	{
		memset(b, 0, sizeof(b));
		for (int i = 1; i < MAX - 1; i++)
		{
			for (int j = 1; j < MAX - 1; j++)
			{
				b[i][j] += a[i][j];
				for (int x = -1; x <= 1; x++)
				{
					for (int y = -1; y <= 1; y++)
					{
						b[i + x][j + y] += a[i][j];
					}
				}
			}
		}
		memcpy(a, b, sizeof(a));
	}
	for (int i = 0; i < MAX; i++)
	{
		for (int j = 0; j < MAX - 1; j++)
		{
			cout << a[i][j] << ' ';
		}
		cout << a[i][MAX - 1] << endl;
	}
	return 0;
}
void propagate( int day ); //propagete????????????????day????
void print(); //????? 
int a[9][9] = {0}, b[9][9] = {0}, m = 0; //a????????b????????,m??????????m???

int main()
{
 	int n; //n??????
	
	cin >> m >> n;
	
	propagate( n );
	print();
	
	return 0;	  
}

void propagate( int day )
{
 	 int num = 0;
 	 
 	 if ( day == 0 )
 	 {
	  	a[4][4] = m; //????????????
		return;   
	 }
	 propagate( day - 1 ); //????????
	  
	 for ( int i = 0; i < 9; i++ )
 	 {
   	  	 for ( int j = 0; j < 9; j++ )
 	 	 {
 	   	  	 b[i][j] = 0; //??????? 
	  	 }
	 }
	 
	 for (int i = 0; i < 9; i++ )
	{
	 	for ( int j = 0; j < 9; j++ )
	 	{
 	  	 	if ( a[i][j] != 0 )
 	  	 	{
 	   	 	   	num = a[i][j]; //num?????????? 
				a[i][j] = 2 * num; //??????????? 
				b[i-1][j-1] += num; //???????????? 
				b[i-1][j] += num;
				b[i-1][j+1] += num;
				b[i+1][j] += num;
				b[i+1][j+1] += num;
				b[i+1][j-1] += num;
				b[i][j+1] += num;
				b[i][j-1] += num; 
		  	}
	   	}
 	}
 	
 	for ( int i = 0; i < 9; i++ )
	{
	 	for ( int j = 0; j < 9; j++ )
	 	{
 	  	 	a[i][j] += b[i][j]; //???????????????? 
	   	}
 	}
 	
 	return;	 
} 

void print()
{
 	 for ( int x = 0; x < 9; x++ )
  	 {
   	  	 for ( int y = 0; y < 9; y++ )
		 {
 	 	  	 if ( y == 0 )
				 cout << a[x][y]; //????????????? 
			 else if ( y == 8 )
			 	  cout << " " << a[x][y] << endl; //?????????????????? 
			 else
			 	 cout << " " << a[x][y]; //?????????? 
   		 } 
	 }
}
int main()
{
	int a[9][9] ={0, 0};
	int n, day;
	
	cin >> n >> day;
	
	a[4][4] = n;
	
	for(int i = 1; i <= day; i ++)
	{
		int b[9][9] = {0, 0};
	
		for(int j = 0; j < 9; j ++)
		for(int k = 0; k < 9; k++)
		{
			if(a[j][k] != 0)
			{
				b[j][k] += a[j][k];
				b[j - 1][k - 1] += a[j][k];
				b[j - 1][k] += a[j][k];
				b[j - 1][k + 1] += a[j][k];
				b[j][k - 1] += a[j][k];
				b[j][k + 1] += a[j][k];
				b[j + 1][k - 1] += a[j][k];
				b[j + 1][k] += a[j][k];
				b[j + 1][k + 1] += a[j][k];
			}
		}
		
		for(int j = 0; j < 9; j ++)
		for(int k = 0; k < 9; k ++)
		a[j][k] += b[j][k];
	}
	
	for(int i = 0; i < 9; i ++)
	{
		cout << a[i][0];
		
		for(int j = 1; j < 9; j ++)
		cout << " " << a[i][j];
		
		cout << endl;
	}
	
	return 0;
}
//fanzhi
int a[10][10] = {0};
void fanzhi();
int main()
{
	int m, n;
	cin >> m >> n;
	a[5][5] = m;
	for(int i = 0; i < n; i++)
		fanzhi();
	for(int i = 1; i <= 9;i++)
	{
		for(int j = 1; j <= 8; j++)
			cout << a[i][j] << ' ';
		cout << a[i][9] << endl;
	}

	cin.get();
	cin.get();
	return 0;
}
void fanzhi()
{
	int b[10][10] = {0};
	for(int i = 1; i < 10; i++)
		for(int j = 1; j < 10; j++)
		{
			b[i][j] += 2 * a[i][j];
			b[i+1][j] += a[i][j];
			b[i-1][j] += a[i][j];
			b[i][j+1] += a[i][j];
			b[i][j-1] += a[i][j];
			b[i+1][j+1] += a[i][j];
			b[i-1][j-1] += a[i][j];
			b[i+1][j-1] += a[i][j];
			b[i-1][j+1] += a[i][j];
		}
	for(int i = 1; i < 10; i++)
		for(int j = 1; j < 10; j++)
			a[i][j] = b[i][j];
	return;
}