#include<stdio.h>
int Y[]={0,1,0,-1};
int X[]={1,0,-1,0};
int main(){
  int a,b,x,y,d[6],i,j,k,n;
  int c[7][7]={
    {0,0,0,0,0,0,0},
    {0,0,3,5,2,4,0},
    {0,4,0,1,6,0,3},
    {0,2,6,0,0,1,5},
    {0,5,1,0,0,6,2},
    {0,3,0,6,1,0,4},
    {0,0,4,2,5,3,0}
  };
  int r[4][4]={
    {0,4,2,5},
    {1,4,3,5},
    {2,4,0,5},
    {3,4,1,5}
  };
  while(scanf("%d",&n),n){
    int h[210][210]={0};
    int u[210][210]={0};
    int bk[7]={0};
   while(n--){
      scanf("%d %d",&a,&b);
      d[0]=7-b;
      d[1]=c[a][b];
      d[2]=b;
      d[3]=7-d[1];
      d[4]=a;
      x=y=100;
    FRONT:
      for(i=6;i>3;i--){
	for(j=0;j<4;j++){
	  if(d[j]==i&&h[y][x]>h[y+Y[j]][x+X[j]]){
	    d[5]=7-d[4];
	    for(k=0;k<3;k++)d[r[j][k]]=d[r[j][k+1]];
	    x+=X[j];
	    y+=Y[j];
	    goto FRONT;
	  }
	}
      }
      h[y][x]++;
      u[y][x]=d[4];
    }
   /*for(i=90;i<110;i++){
     for(j=90;j<110;j++)printf("%d",h[i][j]);printf("\n");
     }//*/
    for(i=0;i<210;i++){
      for(j=0;j<210;j++)bk[u[i][j]]++;
    }
    for(i=1;i<7;i++){
      if(i-1)printf(" ");
      printf("%d",bk[i]);
    }
    printf("\n");
  }
  return 0;
}