#include<bits/stdc++.h>
using namespace std;
int n,ans;
string in[404];
int main(){
  ios::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin>>n;
  for(int i=1;i<=n*4;i++) cin>>in[i];
  for(int k=1;k<=n-3;k++){
  	string cy[5][5];
  	for(int i=1;i<=4;i++){
  	  for(int j=1;j<=4;j++){
  	    cy[i][j]=in[(i-1)*4+j+4*k-4];
	  }
	}
	string str[7];
	for(int i=1;i<=4;i++) str[1]=str[1]+cy[1][i]+' '; 
	for(int i=1;i<=4;i++) str[2]=str[2]+cy[i][4]+' '; 
	for(int i=1;i<=4;i++) str[3]=str[3]+cy[4][5-i]+' '; 
	for(int i=1;i<=4;i++) str[4]=str[4]+cy[5-i][4]+' '; 
	for(int j=1;j<=4;j++){
  	  for(int k=1;k<=4;k++){
  	  	if(j==k) str[5]=str[5]+cy[j][k]+' ';
	  }
	}
  	for(int j=1;j<=4;j++){
  	  for(int k=4;k>=1;k--){
  	  	if(j+k==5) str[6]=str[6]+cy[j][k]+' ';
	  }
	}
	
  }
//  cout<<ans<<'\n';
  cout<<1;
  return 0;
}