#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
  
using namespace std;
  
#define reps(i,f,n) for(int i=f;i<n;i++)
#define repc(i,n) for(int i=0;i<n;i++)
#define rep(i,n) reps(i,0,n)

#define pb push_back

#define X real()
#define Y imag()

const int N = 10;

class P{
	public:
	int x,y,kind;
	P(int x,int y,int kind):x(x),y(y),kind(kind){}
};


class B{
	public:
	int board[N][N];
	B(){rep(i,N)rep(j,N)board[i][j]=0;}
	
	B copy(){
		B b;
		rep(i,N)rep(j,N)b.board[i][j]=board[i][j];
		return b;
	}
};

int color[3][5][5]={
	{
		{0,0,0,0,0},
		{0,0,1,0,0},
		{0,1,1,1,0},
		{0,0,1,0,0},
		{0,0,0,0,0},
	},
	{
		{0,0,0,0,0},
		{0,1,1,1,0},
		{0,1,1,1,0},
		{0,1,1,1,0},
		{0,0,0,0,0},
	},
	{
		{0,0,1,0,0},
		{0,1,1,1,0},
		{1,1,1,1,1},
		{0,1,1,1,0},
		{0,0,1,0,0},
	}
};

bool canput(B& b, P p){
	
	int a = 5;
	int c = 2;
	int d = 0;
	
	if(p.kind!=2){
		a=3;
		c=1;
		d=1;
	}
	
	bool flg = true;
	repc(dy,a){
		repc(dx,a){
			int nx = p.x+dx-c;
			int ny = p.y+dy-c;
			
			if(nx<0 || ny<0 || nx>=N || ny>=N){
				if(b.board[ny][nx]==1)flg=false;
				continue;
			}
			
			if(color[p.kind][dy+d][dx+d]==1 && b.board[ny][nx]==0)flg=false;
		}
	}
	
	return flg;
}

void put(B& b, P p,int rev=1){
	
	int a = 5;
	int c = 2;
	int d = 0;
	
	if(p.kind!=2){
		a=3;
		d=1;
		c=1;
	}
	repc(dy,a){
		repc(dx,a){
			int nx = p.x+dx-c;
			int ny = p.y+dy-c;
			
			if(nx<0 || ny<0 || nx>=N || ny>=N)continue;
			
			if(color[p.kind][dy+d][dx+d]==1){
				b.board[ny][nx]-=rev;
			}
		}
	}
}

vector<P> getcand(B& b){
	vector<P> ret;
	rep(y,N){
		rep(x,N){
			rep(k,3){
				if(canput(b, P(x,y,k))){
					ret.pb(P(x,y,k));
				}
			}
		}
	}
	return ret;
}

bool boardvalid2(B& b){
	B c;
	rep(kind,3){
		rep(y,N){
			rep(x,N){
				P np = P(x,y,kind);
				if(canput(b, np)){
					put(c, np);
				}
			}
		}
	}
	
	rep(i,N){
		rep(j,N){
			if(b.board[i][j]>0 && c.board[i][j]==0)return false;
		}
	}
	return true;
}
bool boardvalid(B& b){
	rep(i,N){
		rep(j,N){
			if(b.board[i][j]<0)return false;
		}
	}
	
	return boardvalid2(b);
}


int main(){
	srand(time(NULL));
	
	int n;
	
	//fprintf(stderr,"n->");
	//cin>>n;
	n=12;
	
	B b;
	
	rep(i,n){
		//int kind = rand()%3;
		
		int kind = 2;
		int x = rand()%6+2;
		int y = rand()%6+2;
		put(b, P(x,y,kind), -1);
	}
	
	printf("%d\n",n);
	rep(i,N){
		rep(j,N)printf("%d ",b.board[i][j]);puts("");
	}
}