semeru/Code-Code-CloneDetection-POJ104 huggingface dataset:
//****************************************
//*?????(11.8) ????????    **
//*?????? 1100012798              **
//*???2011.11.26                     **
//****************************************
int a[9][9] = {0} , m;
void breed(int x,int y,int nf)                             //??????
{
	int xx,yy;
	if (nf != 0)                                           //??????:??
	{
		breed(x,y,nf - 1);                                 //??
		for (xx = x - 1;xx <=  x + 1;xx++)
		{
			for (yy = y - 1;yy <= y + 1;yy++)
			{
				a[xx][yy]+= m;
				breed(xx,yy,nf - 1);
			}
		}
	}
}
int main()
{
	int n , i , j;                                         //??????
	cin >> m >> n;                                         //????
	a[4][4] = m;
	breed(4,4,n);                                          //??
	for (i = 0;i < 9;i++)                                  //??????
	{
		cout << a[i][0];
		for (j = 1;j < 9;j++)
			cout << " " << a[i][j];
		cout << endl;
	}
	return 0;
}
void main(){
long d,i,j,m,n,a[11][11][5]={0,0};
scanf("%d%d",&m,&n);
a[5][5][0]=m;
for(d=1;d<=n;d++)
for(i=1;i<10;i++)
for(j=1;j<10;j++)
a[i][j][d]=
a[i-1][j-1][d-1]
+a[i][j-1][d-1]
+a[i-1][j][d-1]
+a[i][j][d-1]*2
+a[i+1][j-1][d-1]
+a[i+1][j][d-1]
+a[i+1][j+1][d-1]
+a[i-1][j+1][d-1]
+a[i][j+1][d-1];
for(i=1;i<10;i++)printf("%ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
a[i][1][n],
a[i][2][n],
a[i][3][n],
a[i][4][n],
a[i][5][n],
a[i][6][n],
a[i][7][n],
a[i][8][n],
a[i][9][n]);}
//**********************************
//*?????????.cpp          *
//*?  ?????                  *
//*?  ??2013.12.4               *
//**********************************
void judge(int m , int n ,int (*p)[9])
{
	int str[9][9] , i , j ;
	if ( n == 0 )           //??n??0??????n???????
		return ;
	memcpy(str,p,sizeof(str));             //?p???str??????????????
	for ( i = 0 ; i <= 8 ; i++ )
	{
		for ( j = 0 ; j <=8 ; j++ )
			if (str[i][j] != 0)
			{
				if ( i != 0 )           //???????????????p???
				{
					if ( j != 0 )
						p[i-1][j-1] += str[i][j] ;
					if ( j != 8 )
						p[i-1][j+1] += str[i][j] ;
					p[i-1][j] += str[i][j] ;
				}
				if ( i != 8 )
				{
					if ( j != 0 )
						p[i+1][j-1] += str[i][j] ;
					if ( j != 8 )
						p[i+1][j+1] += str[i][j] ;
					p[i+1][j] += str[i][j] ;
				}
				if ( j != 0 )
					p[i][j-1] += str[i][j] ;
				if ( j != 8 )
					p[i][j+1] += str[i][j] ;
				p[i][j] += str[i][j] ;
			}
	}
	judge(m,n-1,p);                //?????
}
void output(int (*p)[9])
{
	int i , j ;
	for ( i = 0 ; i <= 8 ; i++ )
	{
		for ( j = 0 ; j <= 8 ; j++ )
		{
			cout << p[i][j] ;
			if ( j != 8 )
				cout << " " ;
			else 
				cout << endl ;
		}
	}
}
int main ()
{
	int m , n ,p[9][9]={0};
	cin >> m >> n ;
	p[4][4]=m;
	judge(m,n,p);           //????
	output(p);              //????
	return 0 ;
}
/*
 * 2.Cap
 *
 *  Created on: 2011-11-22
 *      Author: Administrator
 */

int a[10][10] = {0}, b[10][10] = {0};
void born( int i, int j )
{
	int num = b[i][j];
	if ( i > 1 )
		a[i - 1][j] += num;
	if ( i > 1 && j > 1 )
		a[i - 1][j - 1] += num;
	if ( j > 1 )
		a[i][j - 1] += num;
	if ( i < 9 && j > 1 )
		a[i + 1][j - 1] += num;
	if ( i < 9 )
		a[i + 1][j] += num;
	if ( i < 9 && j < 9 )
		a[i + 1][j + 1] += num;
	if ( j < 9 )
		a[i][j + 1] += num;
	if ( i > 1 && j < 9 )
		a[i - 1][j + 1] += num;
	a[i][j] += num;
}

int main()
{
	int m, n, i, j, k;
	cin >> m >> n;
	a[5][5] = m;
	for ( k = 1; k <= n; k++ )
	{
		for ( i = 1; i <= 9; i++ )
		{
			for ( j = 1; j <= 9; j++ )
			{
				b[i][j] = a[i][j];
			}

		}
		for ( i = 1; i <= 9; i++ )
		{
			for ( j = 1; j <= 9; j++ )
			{
				born( i, j );
			}
		}
		memset( b, 0, sizeof(b));
	}
	for ( i = 1; i <= 9; i++ )
	{
		for ( j = 1; j <= 8; j++ )
		{
			cout << a[i][j] << " ";
		}
		cout << a[i][9];
		cout << endl;
	}
	return 0;
}
int main()
{
	int xijun[11][11]={0};
	for (int i=0;i<11;i++)
	{
		for (int j=0;j<11;j++)
		{
			xijun[i][j]=0;
		}
	}
	int result[11][11]={0};
	int m=0;
	int n=0;
	cin>>m>>n;
	xijun[5][5]=m;
	result[5][5]=m;
	for (int x=0;x<n;x++)
	{
	    for (int i=0;i<11;i++)
		{
			for (int j=0;j<11;j++)
			{
				xijun[i][j]=result[i][j];
			}
		}
		for (int i=1;i<10;i++)
		{
			for (int j=1;j<10;j++)
			{
				result[i][j]=2*xijun[i][j]+xijun[i][j+1]+xijun[i][j-1]+xijun[i+1][j]+xijun[i-1][j]+xijun[i+1][j+1]+xijun[i+1][j-1]+xijun[i-1][j+1]+xijun[i-1][j-1];
			}
		}



	}
	for (int i=1;i<10;i++)
	{
		for (int j=1;j<10;j++)
		{
			if (j==1) cout<<result[i][j];
			else if (j==9) cout<<" "<<result[i][j]<<endl;
			else cout<<" "<<result[i][j];
		}
	}

	/*int i=0;
	int j=0;
	for(i=1;i<10;i++)
         {
             bool p=0;
             for(j=1;j<10;j++)
         {
             if(p) cout<<" ";
             p=1;
             cout<<result[i][j];
         }
         cout<<endl;
         }

*/return 0;
}
int main()
{
	int grids[9][9] = {0}, daysLeft, history[81][3], historyCount = 0, x, y;
	cin >> grids[4][4];
	for (cin >> daysLeft; daysLeft > 0; daysLeft--)
	{
		historyCount = 0;
		for (y = 0; y < 9; y++)
			for (x = 0; x < 9; x++)
				if (grids[x][y])
				{
					history[historyCount][0] = x;
					history[historyCount][1] = y;
					history[historyCount][2] = grids[x][y];
					historyCount++;
				};
		for (int i = 0; i < historyCount; i++)
		{
			x = history[i][0];
			y = history[i][1];
			int val = history[i][2];
			if (x > 0)
			{
				grids[x - 1][y] += val;
				if (y > 0)
					grids[x - 1][y - 1] += val;
				if (y < 8)
					grids[x - 1][y + 1] += val;
			}
			if (x < 8)
			{
				grids[x + 1][y] += val;
				if (y > 0)
					grids[x + 1][y - 1] += val;
				if (y < 8)
					grids[x + 1][y + 1] += val;
			}
			if (y > 0)
				grids[x][y - 1] += val;
			if (y < 8)
				grids[x][y + 1] += val;
			grids[x][y] += val;
		}
	}
	for (y = 0; y < 9; y++)
	{
		cout << grids[0][y];
		for (x = 1; x < 9; x++)
			cout << ' ' << grids[x][y];
		cout << endl;
	}
	return 0;
}
int main()
{
	int array[9][9] ;
	int temp[9][9] ;
	int i , j , k , p ;
	for(i = 0 ;i < 9 ;i ++)
		for(j = 0 ; j < 9 ; j ++)
		{
			array[i][j] = 0 ;
			temp[i][j] = 0 ;
		}		
	int m ;
	int n ;
	cin >> m >>n ;
	array[4][4] = m ;
	while(n)
	{
		for(i = 0; i < 9 ;i ++)//??????
			for(j = 0 ;j < 9 ; j ++)
			{
				if(i - 1 >= 0 && j - 1 >= 0 && array[i][j] != 0)//??i,j?????????
				{
					for(k = i - 1 ;k <= i + 1 ;k ++)
						for(p = j - 1 ; p <= j + 1 ;p ++)
						{
							if(k == i && p == j)
							{
								temp[i][j] = temp[i][j] + array[i][j]*2 ;
							}else
							{
								temp[k][p] = temp[k][p] + array[i][j] ;
							}
						}
				}
			}
		for(i = 0 ;i < 9 ;i ++)//???????????
			for(j = 0 ; j < 9 ; j ++)
			{
				array[i][j] = temp[i][j] ;
				temp[i][j] = 0 ;
			}
		n -- ;
	}
	for(i = 0 ;i < 9 ;i ++)//??
	{
		for(j = 0 ; j < 9 ; j ++)
		{
			if(j == 8)
				cout<<array[i][j];
			else
				cout<<array[i][j]<<" ";
		}
		cout<<endl ;
	}

}
int a[10][10],b[10][10],i,j,k;
int main()
{
    int m,n,x1,x2,y1,y2;
    for(i=0;i<10;i++)
    for(j=0;j<10;j++)
    {
        a[i][j]=0;
        b[i][j]=0;
    }
    scanf("%d %d",&m,&n);
    a[4][4]=m;
    x1=y1=x2=y2=4;
    for(i=0;i<n;i++)
    {
        for(j=x1-1;j<=x2+1;j++)
        for(k=y1-1;k<=y2+1;k++)
        b[j][k]=a[j][k]+a[j-1][k-1]+a[j-1][k]+a[j-1][k+1]+a[j][k-1]+a[j][k+1]+a[j+1][k-1]+a[j+1][k]+a[j+1][k+1];
        for(j=0;j<9;j++)
        for(k=0;k<9;k++)
        a[j][k]=a[j][k]+b[j][k];
        x1--;
        y1--;
        x2++;
        y2++;
    }
    for(j=0;j<9;j++)
    for(k=0;k<9;k++)
    if(k!=8)
    printf("%d ",a[j][k]);
    else
    printf("%d\n",a[j][k]);
}
/*
 * 321.cpp
 *
 *  Created on: 2011-1-9
 *      Author: jsgl
 */

int a[9][9];
int b[9][9];
void fanzhi(int n)
{   if(n==0) return;
	int i,j;
	for(i=0;i<9;i++){
		for(j=0;j<9;j++){
			if(a[i][j]!=0){
				b[i][j]=b[i][j]+a[i][j]*2;
				b[i][j+1]=b[i][j+1]+a[i][j];
				b[i+1][j+1]=b[i+1][j+1]+a[i][j];
				b[i-1][j+1]=b[i-1][j+1]+a[i][j];
				b[i][j-1]=b[i][j-1]+a[i][j];
				b[i-1][j-1]=b[i-1][j-1]+a[i][j];
				b[i+1][j-1]=b[i+1][j-1]+a[i][j];
				b[i+1][j]=b[i+1][j]+a[i][j];
				b[i-1][j]=b[i-1][j]+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;

			}
	}
	fanzhi(n-1);


}


int main(){
	int i,j;
int m,n;

cin>>m;
cin>>n;
for(i=0;i<9;i++){
	for(j=0;j<9;j++){
		a[i][j]=0;
		if(i==4&&j==4) a[i][j]=m;
          b[i][j]=0;
	}
}
fanzhi(n);



for(i=0;i<9;i++){
	for(j=0;j<9;j++){
		if(j!=8)
cout<<a[i][j]<<" ";
		else cout<<a[i][j];
	}
	cout<<endl;
}

}
int main()
{
	long int a[11][11] = {0}, b[11][11] = {0};
	int m, n, i, j, k, p, q;
	cin >> m >> n;
	a[5][5] = m;
	for (k = 1; k <= n; k++)
	{
		for (i = 0; i <= 10; i++)
			for (j = 0; j <= 10; j++)
				b[i][j] = a[i][j];
		for (i = 5 - k; i <= 5 + k; i++)
			for (j = 5 - k; j <= 5 + k; j++)
				for(p = i - 1; p <= i + 1; p++)
					for(q = j - 1; q <= j + 1; q++)
						a[i][j] = a[i][j] + b[p][q];
	}
	for (i = 1; i <= 9; i++)
		for(j = 1; j <= 9; j++)
		{
			if (j == 9)
				cout << a[i][j] << endl;
			else
				cout << a[i][j] << " ";
		}
	return 0;
}
//********************************
//*???????????  **
//*?????? 1300012946 **
//*???2013.11.28  **
//********************************
int a[9][9]={0},b[9][9]={0};//???a????????????,???b??????????????????
void breed(int n)
{
	if (n == 0)//??????0,?????
		return;
	int temp,p,q,i,j;
	for (p=0 ; p<9 ; p++)//???b?0
		for (q=0 ; q<9 ; q++)
			b[p][q]=0;
	for (p=0 ; p<9 ; p++)
		for (q=0 ; q<9 ; q++)
		{
			if (a[p][q] != 0)
			{
				temp=a[p][q];//???????????
				for (i=p-1 ; i<=p+1 ; i++)
					for (j=q-1 ; j<=q+1 ; j++)
						b[i][j] += temp;//??????????????
			}
		}
	for (p=0 ; p<9 ; p++)
		for (q=0 ; q<9 ; q++)//??????????
			a[p][q] += b[p][q];
	breed(n-1);
}


int main ()
{
	int m,n,i,j;
	cin >> m >> n;
	a[4][4] = 1;//m??????????1????m?
	breed(n);//????breed,??n????
	for (i=0 ; i<9 ; i++)//?????,?????????
	{
		cout << m * a[i][0];
		for (j=1 ; j<9 ; j++)
		{
			cout << " " << m * a[i][j];
		}
		cout << endl;
	}
	return 0;
}
int main()
{int a[11][11],b[11][11],m,n,i,j,k;
cin>>m>>n;
for(i=0;i<11;i++)
{for(j=0;j<11;j++)
{a[i][j]=0;
b[i][j]=0;}}
a[5][5]=m;
for(k=0;k<n;k++)
{for(i=1;i<10;i++)
{for(j=1;j<10;j++)
b[i][j]=a[i][j]+a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+a[i][j-1]+a[i][j]+a[i][j+1]+a[i+1][j-1]+a[i+1][j]+a[i+1][j+1];}
for(i=1;i<10;i++)
{for(j=1;j<10;j++)
a[i][j]=b[i][j];}}
for(i=1;i<10;i++)
{for(j=1;j<9;j++)
{cout<<a[i][j]<<" ";}
cout<<a[i][9]<<endl;}
return 0;}
int a[11][11];

void start(int n)
{
	a[5][5]=n;
}


void day()
{
	int b[11][11];
	for (int i=1; i<=9; i++)
	{
		for (int j=1; j<=9;j++ )
		{
			b[i][j]=0;
		}
	}
	for (int i=1; i<=9; i++)
	{
		for (int j=1; j<=9;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<=9; i++)
	{
		for (int j=1; j<=9;j++ )
		{
			a[i][j]=b[i][j];
		}
	}
}


int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	start(n);
	while (m--)
	{
		day();
	}
	
	for (int i=1; i<=9; i++)
	{
		for (int j=1;j<9 ;j++ )
		{
			printf("%d ",a[i][j]);
		}
		printf("%d\n",a[i][9]);
	}
	return 0;
}
int main()
{
	int a[9][9]={0},b[9][9]={0};
	int m,n,i,j,k;
	scanf("%d%d",&m,&n);
	a[4][4]=m;
	for(k=0;k<n;k++)
	{
		for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
				b[i][j]+=2*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][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]+=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;
			}
		}
	}
				for(i=0;i<9;i++)
		{
			for(j=0;j<9;j++)
			{
				if(j==0)
				printf("%d",a[i][j]);
				else
					printf(" %d",a[i][j]);
			}
			printf("\n");
		}
				return 0;
}
int main()
{
	int a[5][11][11] = {0};
	int m, n, i, j, k;
	cin >> m >> n;
	a[0][5][5] = m;
	for(i = 1; i < n + 1; i++)
	{
		for(k = 1; k < 10; k++)
			for(j = 1; j < 10; j++)
			{
				a[i][k][j] = a[i - 1][k][j] * 2 + a[i - 1][k - 1][j] + a[i - 1][k + 1][j] + a[i - 1][k][j + 1] + a[i - 1][k][j - 1] + a[i - 1][k + 1][j+1] + a[i - 1][k + 1][j -1] + a[i - 1][k - 1][j + 1] + a[i - 1][k - 1][j - 1];
			}
	}
	for(i = 1; i < 10; i++)
	{
		cout << a[n][i][1];
		for(j = 2; j < 10; j++)
			cout << ' ' << a[n][i][j];
		cout << endl;
	}
	return 0;
}
int main()
{
	int a[9][9],b[9][9];                                           //?????????????
	int i=0,j=0,m=0,n=0,k=0,l=0;
	cin>>m>>n;

	for ( i=0;i<9;i++ )
	{
		for ( j=0;j<9;j++ )
		{
			a[i][j]=b[i][j]=0;
		}
	}
	b[4][4]=m;

	while ( k<n )
	{
		for ( i=0;i<9;i++ )                                        //???a????????
		{
			for ( j=0;j<9;j++ )
			{
				if (b[i][j]!=0)
				{
					a[i-1][j-1]=a[i-1][j-1]+b[i][j];
					a[i-1][j]=a[i-1][j]+b[i][j];
					a[i-1][j+1]=a[i-1][j+1]+b[i][j];
					a[i][j-1]=a[i][j-1]+b[i][j];
					a[i][j+1]=a[i][j+1]+b[i][j];
					a[i+1][j-1]=a[i+1][j-1]+b[i][j];
					a[i+1][j]=a[i+1][j]+b[i][j];
					a[i+1][j+1]=a[i+1][j+1]+b[i][j];
				}
			}
		}
		
		for ( i=0;i<9;i++ )                                        //?b???????????
		{
			for ( j=0;j<9;j++ )
			{
				b[i][j]=2*b[i][j]+a[i][j];
				a[i][j]=0;                                         //???a????????
			}
		}                                                          //??b??????????????????
		k++;
	}
	
	for ( i=0;i<9;i++ )
	{
		for ( j=0;j<9;j++ )
		{
			if ( j!=8 )
				cout<<b[i][j]<<" ";
			else if ( j==8 )
				cout<<b[i][j]<<endl;
		}
	}
	return 0;
}
//????
int bac[5][11][11] = {0};                    //bac???????n??i,j???????

void boom (int m,int n)
{
	int i,j,d1,d2;
	if (n == 0)								//?n=0??????
		bac[n][5][5] = m;
	else									//?n>1?????????
		boom (m , n - 1);
	if (n > 0)
		for (i = 1; i <= 9; i++)
			for (j = 1; j <= 9; j++)
			{
				bac[n][i][j] = bac[n - 1][i][j];
				for (d1 = -1; d1 <= 1; d1++)
					for (d2 = -1; d2 <= 1; d2++)
						bac[n][i][j] += bac[n - 1][i + d1][j + d2];    //?n>1??????????
			}
}

int main()
{
	int m,n,i,j;
	cin >> m >> n;
	boom (m,n);                                       //?????m??????n?????
	for (i = 1; i <= 9; i++)                          //???????
	{	for (j = 1; j <= 8; j++)  
			cout << bac[n][i][j] << ' ';
		cout << bac[n][i][9] << endl;
	}
	return 0;
}
int a[9][9];
int b[9][9];
main()
{
	int m,n,i,j,k;
	scanf("%d %d",&m,&n);
	a[4][4]=m;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<9;j++)
			for(k=0;k<9;k++)
				b[j][k]=a[j][k];
		a[0][0]=2*b[0][0]+b[0][1]+b[1][0]+b[1][1];
		a[0][8]=2*b[0][8]+b[0][7]+b[1][8]+b[1][7];
		a[8][0]=2*b[8][0]+b[7][0]+b[8][1]+b[7][1];
		a[8][8]=2*b[8][8]+b[8][7]+b[7][8]+b[7][7];
		for(j=1;j<8;j++)
			a[0][j]=2*b[0][j]+b[0][j-1]+b[0][j+1]+b[1][j]+b[1][j-1]+b[1][j+1];
		for(j=1;j<8;j++)
			a[8][j]=2*b[8][j]+b[8][j-1]+b[8][j+1]+b[7][j]+b[7][j-1]+b[7][j+1];
		for(j=1;j<8;j++)
			a[j][0]=2*b[j][0]+b[j-1][0]+b[j+1][0]+b[j][1]+b[j-1][1]+b[j+1][1];
		for(j=1;j<8;j++)
			a[j][8]=2*b[j][8]+b[j-1][8]+b[j+1][8]+b[j][7]+b[j-1][7]+b[j+1][7];
		for(j=1;j<8;j++)
			for(k=1;k<8;k++)
				a[j][k]=2*b[j][k]+b[j-1][k]+b[j+1][k]+b[j][k-1]+b[j][k+1]+b[j-1][k-1]+b[j-1][k+1]+b[j+1][k-1]+b[j+1][k+1];
	}
	for(i=0;i<9;i++)
		for(j=0;j<9;j++)
		{
			if(j!=8)
				printf("%d ",a[i][j]);
			else
				printf("%d\n",a[i][j]);
		}
}
int main ()
{
	int i, j, k, num, day;
	int a[20][20] = {0};
	int b[20][20] = {0};
	int temp[20][20] = {0};
	cin >> num >> day;
	a[5][5] = num;
	for ( k = 1; k <= day; k++ )
	{
		for ( i = 1; i <= 9; i++ )
		{
			for ( j = 1; j <= 9; j++ )
				a[i][j]+= -b[i][j] ;
		}
		for ( i = 1; i <= 9; i++ )
		{
			for ( j = 1; j <= 9; j++ )
				b[i][j] = a[i][j];
		}
		for ( i = 1; i <= 9; i++ )
		{
			for ( j = 1; j <= 9; j++ )
				if ( a[i][j] != 0 )
				{
					temp[i+1][j]+= a[i][j];
					temp[i-1][j]+= a[i][j];
					temp[i+1][j+1]+= a[i][j];
					temp[i-1][j+1]+= a[i][j];
					temp[i+1][j-1]+= a[i][j];
					temp[i-1][j-1]+= a[i][j];
					temp[i][j+1]+= a[i][j];
					temp[i][j-1]+= a[i][j];
					temp[i][j]+= 2 * a[i][j];
				}
		}
		for ( i = 1; i <= 9; i++ )
		{
			for ( j = 1; j <= 9; j++ )
				a[i][j]+=temp[i][j], temp[i][j] = 0;
		}
	}

	for ( i = 1; i <= 9; i++ )
	{
		for ( j = 1; j <= 9; j++ )
			a[i][j]+= -b[i][j] ;
	}

	for ( i = 1; i <= 9; i++ )
	{
		for ( j = 1; j <= 8; j++ )
			cout << a[i][j] << " ";
		cout << a[i][9] << endl;
	}
	return 0;
}
int map[2][12][12];
void Make(int,int,int);
int main()
{
    int i,j;
    int m,n,turn=0;
    memset(map,0,sizeof(map));
    map[0][5][5]=1;
    map[1][5][5]=1;
    cin>>m>>n;
    for(;n>0;--n)
    {
        turn=1-turn;
        for(i=0;i<12;++i)
        {
            for(j=0;j<12;++j)
            {
                map[1-turn][i][j]=0;
            }
        }
        for(i=1;i<=9;++i)
        {
            for(j=1;j<=9;++j)
            {
                Make(i,j,turn);
            }
        }
    }
    for(i=1;i<=9;++i)
    {
        cout<<map[1-turn][i][1]*m;
        for(j=2;j<=9;++j)
        {
            cout<<" "<<map[1-turn][i][j]*m;
        }
        cout<<endl;
    }
    return 0;
}
void Make(int x,int y,int t)
{
     int n=map[t][x][y];
     map[1-t][x][y]+=n*2;
     map[1-t][x-1][y]+=n;
     map[1-t][x+1][y]+=n;
     map[1-t][x][y-1]+=n;
     map[1-t][x][y+1]+=n;
     map[1-t][x-1][y-1]+=n;
     map[1-t][x-1][y+1]+=n;
     map[1-t][x+1][y-1]+=n;
     map[1-t][x+1][y+1]+=n;
     return;
}
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;
	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-1]+=a[i][j];
					b[i][j+1]+=a[i][j];
					b[i-1][j-1]+=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]+=a[i][j];
					b[i+1][j+1]+=a[i][j];
					b[i][j]+=a[i][j]*2;
				}
			}
		}
		for(i=0;i<9;i++){
			for(j=0;j<9;j++){
				a[i][j]=b[i][j];
				b[i][j]=0;
			}
		}
	}
	for(i=0;i<9;i++){
			for(j=0;j<8;j++){
				printf("%d ",a[i][j]);
			}
			printf("%d\n",a[i][8]);
	}
	return 0;
}
int num[9][9],im[9][9];
main()
{
	int i,j,k,m,n;
	scanf("%d%d",&m,&n);
	num[4][4]=m;
	for(i=0;i<n;i++)
	{
		for(j=0;j<9;j++)
			for(k=0;k<9;k++)
				im[j][k]=0;
		for(j=1;j<8;j++)
		{
			for(k=1;k<8;k++)
			{
				im[j-1][k]+=num[j][k];
				im[j][k]+=2*num[j][k];
				im[j][k-1]+=num[j][k];
				im[j+1][k]+=num[j][k];
				im[j][k+1]+=num[j][k];
				im[j-1][k-1]+=num[j][k];
				im[j-1][k+1]+=num[j][k];
				im[j+1][k-1]+=num[j][k];
				im[j+1][k+1]+=num[j][k];
			}
		}
		for(j=0;j<9;j++)
			for(k=0;k<9;k++)
				num[j][k]=im[j][k];
	}
	for(j=0;j<9;j++)
	{
		for(k=0;k<9;k++)
		{
			printf("%d%c",num[j][k],k==8?'\n':' ');
		}
	}
}
void prop(int num1[11][11],int num2[11][11],int n)
{
     int i,j;
     if(n)
     {
     for(i=1;i<10;i++)for(j=1;j<10;j++)
         num2[i][j]= num1[i-1][j-1]+num1[i-1][j]+num1[i-1][j+1]
                    +num1[i][j-1]+num1[i][j]*2+num1[i][j+1]
                    +num1[i+1][j-1]+num1[i+1][j]+num1[i+1][j+1];
     prop(num2,num1,n-1);
     }
} 

main()
{
      int m,n,num1[11][11]={0},num2[11][11]={0};
      int i,j;
      scanf("%d %d",&m,&n);
      num1[5][5]=m;
      prop(num1,num2,n);
      if(n%2==0)
      for(i=1;i<10;i++)
      {
          for(j=1;j<9;j++) printf("%d ",num1[i][j]);
          printf("%d\n",num1[i][9]);
      }
      else
      for(i=1;i<10;i++)
      {
          for(j=1;j<9;j++) printf("%d ",num2[i][j]);
          printf("%d\n",num2[i][9]);
      }
      
}
/**
 *@file 2.cpp
 *@author ???
 *@date 2013-12-03
 *@description ????????
 */


int a[11][11]={0}, b[11][11]={0}, m, n;

void xi(int n)
{
    int i, j, p;
    if(n==0)
        a[5][5]=m;
    
    else
    {
        xi(n-1);
        p=0;
        for(i=1; i<=9; i++)
        {
            for(j=1; j<=9; j++)
            {
                if(a[i][j]!=0)
                {
                    p++;
                }
            }
        }
        p= sqrt(p)/2;
        for(i=5-p; i<=5+p; i++)
        {
            for(j=5-p; j<=5+p; j++)
            {
           
                b[i][j]=a[i][j];
                a[i][j]=a[i][j] * 2;
            }
        }
        for(i=5-p; i<=5+p; i++)
        {
            for(j=5-p; j<=5+p; j++)
            {
                a[i-1][j]+=b[i][j];
                a[i+1][j]+=b[i][j];
                a[i][j+1]+=b[i][j];
                a[i][j-1]+=b[i][j];
                a[i-1][j+1]+=b[i][j];
                a[i-1][j-1]+=b[i][j];
                a[i+1][j+1]+=b[i][j];
                a[i+1][j-1]+=b[i][j];
                
        
            }
        }
        
        
    }
    
    
    
}

int main()
{
    int i, j;
    cin >> m >> n;
    xi(n);
    for(i=1; i<=9; i++)
    {
        for(j=1; j<=9; j++)
        {
            cout << a[i][j];
            if(j<=8)
                cout << " ";
        }
        cout << endl;
    }
    return 0;
    
}
int m[L+5][L+5]={0},tmp[L+5][L+5]={0};
int i=0,j=0,k=0;
int n;
main()
{     
      scanf("%d%d",&m[4][4],&n);
      for(k=1;k<=n;k++)
      {
                         memset(tmp,0,sizeof(tmp));
      for(i=0;i<=L-1;i++) 
      {
                          for(j=0;j<=L-1;j++)
                          {
                                             tmp[i][j]=2*m[i][j]+m[i-1][j-1]+m[i][j-1]+m[i+1][j-1]+m[i+1][j]+m[i-1][j]+m[i+1][j+1]+m[i][j+1]+m[i-1][j+1];
                          }
      }
      for(i=0;i<=L-1;i++) 
      {
                          for(j=0;j<=L-1;j++)
                          {
                                             m[i][j]=tmp[i][j];
                          }
      }
      }
      for(i=0;i<=L-1;i++)
      {
           printf("%d %d %d %d %d %d %d %d %d\n",m[i][0],m[i][1],m[i][2],m[i][3],m[i][4],m[i][5],m[i][6],m[i][7],m[i][8]);
      }
      getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();getchar();
}
int main()
{int a[11][11],b[11][11];
int i,j,k,n,m;
scanf("%d %d",&m,&n);
for(i=0;i<11;i++)
for(j=0;j<11;j++)
a[i][j]=0;
a[5][5]=1;

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

for(i=1;i<10;i++)
{for(j=1;j<10;j++)
{if((j==1)&&(i!=0))
printf("\n");
printf("%d",a[i][j]*m);
if(j!=9)
printf(" ");
}
}
getchar();
getchar();
    }
const int N = 9;

int n,m;
int a[N+1][N+1];

void dfs(int x, int y, int s, int d)
{
	if (x<1 || x>N || y<0 || y>N) return;
	if (d==m)
	{
		a[x][y] += s;
		return;
	}
	dfs(x,y,s*2,d+1);
	for (int dx=-1;dx<=1;dx++)
		for (int dy=-1;dy<=1;dy++)
			if (dx!=0 || dy!=0)
				dfs(x+dx,y+dy,s,d+1);
}

int main()
{
	scanf("%d%d",&n,&m);
	memset(a,0,sizeof a);
	dfs(5,5,n,0);
	for (int i=1;i<=N;i++)
	{
		for (int j=1;j<N;j++) printf("%d ",a[i][j]);
		printf("%d\n",a[i][N]);
	}
	
	return 0;
}
//*********************
//  ????????
//  ???  1300062709
//  2013.12.09
//*********************
int shu[9][9] = {0};
int aa[9][9] = {0};
int x,y;
int n, m, i, j;
void grems(int x, int y)
{
	if ( x+1<9&&y+1<9&&x-1>=0&&y-1>=0)
	{
		shu[x+1][y+1] += aa[x][y];
		shu[x+1][y] += aa[x][y];
		shu[x+1][y-1] += aa[x][y];
		shu[x][y+1] += aa[x][y];
		shu[x][y-1] += aa[x][y];
		shu[x-1][y] += aa[x][y];
		shu[x-1][y+1] += aa[x][y];
		shu[x-1][y-1] += aa[x][y];
	}
	 shu[x][y] += 2 * aa[x][y];
}
int main()
{
	cin >> m >> n;
	aa[4][4]=m;
	while(n!=0)
	{
		for ( i = 0 ; i < 9 ; i++ )
		{
			for ( j = 0 ; j < 9; j++ )
			{
				if(aa[i][j]>0)
					grems(i,j);
			}
		}
		for ( i = 0 ; i < 9 ; i++ )
		{
			for ( j = 0 ; j < 9; j++ )
			{
				aa[i][j] = shu[i][j];
			}
		}
		if ( n > 0)
		{
			for ( i = 0 ; i < 9 ; i++ )
			{
				for ( j = 0 ; j < 9; j++ )
				{
					shu[i][j]=0;
				}
			}
		}
		n--;
	}
	for ( i = 0 ; i < 9 ; i++ )
	{
		for ( j = 0 ; j < 8 ; j++ )
			cout << aa[i][j] << ' ' ;
		cout << aa[i][8] << endl;
	}
	return 0;
}