#include <bits/stdc++.h>
using namespace std;
char in[100], out[100];
char S[1100][1100];
char C[5]="gsh";
char ss[5] = "gshs";
int xx[8]={-1,-1,-1,0,0,1,1,1};
int yy[8]={-1,0,1,-1,1,-1,0,1};
int f(int a, int b){
	int s=0,i,j,ii,jj;
	for(i=0;i<8;i++){
		ii = a;
		jj = b;
		for(j=0;j<4;j++){
			//cout <<ss[j] <<" "<<S[ii][jj] <<",";
			if(ii<0 or jj< 0 or ss[j]!=S[ii][jj]) break;
			ii = ii + xx[i];
			jj = jj + yy[i];
		}
		if(j==4)s++;
	}
	return s;
}
int main(){
	int k, i,j,s = 0,n;
	srand((unsigned int)time(NULL));
	for(int I=2;I<=20;I++){
		s = 0;
		sprintf(in,".%d.in",I);
	    freopen(in,"w",stdout);
	    n = I * 50;
	    printf("%d\n",n);
	    for(i=0;i<n;i++){
	    	for(j=0;j<n;j++){
	    		k = rand()%3;
	    		S[i][j]=C[k];
			}
			printf("%s\n",S[i]);
		}
	    for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(S[i][j]=='g'){
					s = s + f(i,j);
				}
			}
		}
	    sprintf(out,".%d.out",I);
	    freopen(out,"w",stdout);
	    cout << s;
	}
}
