#include<stdio.h>
#include<string.h>
#define p_x 100
#define p_y 100
int high[200][200];
int deme[200][200];
char* dtable[7][7]={{"none","none","none","none","none","none","none"},
					{"none","none","2354","3542","4235","5423","none"},
					{"none","1463","none","3146","4631","none","6314"},
					{"none","1265","2651","none","none","5126","6512"},
					{"none","1562","2156","none","none","5621","6215"},
					{"none","1364","none","3641","4136","none","6413"},
					{"none","none","2453","3245","4532","5324","none"}};
int vector[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
					
int judgefunc(char* a,char* b){
	return (*b)-(*a);
}
char selectway(int top,int front,int num){//num番目に大きな数の位置を返す
	char* i;
	char buf[5];
	strcpy(buf,dtable[top][front]);
	qsort(buf,4,sizeof(char),judgefunc);
//	puts(dtable[top][front]);
	i=strchr(dtable[top][front],buf[num-1]);
	return i-dtable[top][front];
}
int checkroll(int nx,int ny,int way){//nx,nyの位置からway方向へ落とせるかいなか
	return (high[nx][ny]>high[nx+vector[way][0]][ny+vector[way][1]]);
}

int diceroll(int top,int front,int px,int py){

	int i;
	int flag=0;
	for(i=1;i<5;i++){//i番目に大きな面へ転がせるかチェック]
		int way=selectway(top,front,i);
		if(dtable[top][front][way]>='4'&&checkroll(px,py,way)){
			//転がせる時
			flag=1;
		//	printf("%d to turn\n",way);
			//次のtopとfrontを決める
			int ntop=7-(dtable[top][front][way]-'0');
			int nfront;
			if(way==0){
				nfront=top;
			}
			else if(way==2){
				nfront=7-top;
			}
			else {
				nfront=front;
			}			
			diceroll(ntop,nfront,px+vector[way][0],py+vector[way][1]);
			break;
		}
	}
	//もうころがれない
	
	if(flag==0){
		//puts("high++");
		high[px][py]++;
		deme[px][py]=top;
	}
	return 0;
}
int main(){
	int n;
	int i,j,k;
	int top,front;
	int ans[6];
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;
		for(i=0;i<6;i++){//初期化
			ans[i]=0;
		}
		for(i=0;i<200;i++){
			for(j=0;j<200;j++){
				high[i][j]=0;
				deme[i][j]=0;
			}
		}
		for(i=0;i<n;i++){//入力
			scanf("%d %d",&top,&front);
			diceroll(top,front,p_x,p_y);
		}
		for(i=0;i<200;i++){
			for(j=0;j<200;j++){//答えを算出
				if(1<=deme[i][j]&&deme[i][j]<=6){
					ans[deme[i][j]-1]++;
				}
			}
		}
		printf("%d %d %d %d %d %d\n",ans[0],ans[1],ans[2],ans[3],ans[4],ans[5]);
	}

	return 0;
}