#include<stdio.h>
#include<string.h>
int n,f,t,i,j,r[7],h[105][105],num[105][105];
int rt[6][6]={{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};

void rot(int *t,int *f,int d)
{
	int x;
	if(d==0){x=*t;*t=7-*f;*f=x;}
	else if(d==1){*t=7-rt[*t-1][*f-1];}
	else if(d==2){x=*f;*f=7-*t;*t=x;}
	else{*t=rt[*t-1][*f-1];}
}

void drop(int y,int x)
{
	int i,j,mv[5]={0,1,0,-1,0},d[4]={f,rt[t-1][f-1],7-f,7-d[1]};
	for(i=6;i>3;i--)
		for(j=0;j<4;j++)
			if(d[j]==i&&h[y][x]>h[y+mv[j+1]][x+mv[j]])
			{
				rot(&t,&f,j);
				drop(y+mv[j+1],x+mv[j]);
				return;
			}
	h[y][x]++;
	num[y][x]=t;
}

int main()
{
	for(;scanf("%d",&n),n;)
	{
		memset(r,0,sizeof(r));
		memset(h,0,sizeof(h));
		memset(num,0,sizeof(num));
		for(;n--;)
		{
			scanf("%d%d",&t,&f);
			drop(51,51);
		}
		for(i=0;i<105;i++)
			for(j=0;j<105;j++)
				r[num[i][j]]++;
		for(i=1;i<7;i++)
			printf("%d%s",r[i],i==6?"\n":" ");
	}
	return 0;
}