#include<stdio.h>
#define rep(i,n) for(int i=0; (i)<(n); (i)++)
typedef struct{
    int num;
    int h;
}Position;
Position pos[200][200];
const int dice[7][7]={{0,0,0,0,0,0,0},{0,0,4,2,5,3,0},{0,3,0,6,1,0,4},{0,5,1,0,0,6,2},
    {0,2,6,0,0,1,5},{0,4,0,1,6,0,3},{0,0,3,5,2,4,0}};
void init(){
    rep(i,200) rep(j,200) pos[i][j].num=-1,pos[i][j].h=0;
}
int left(int top,int front){
    if(dice[top][front]==0) printf("エラー\n");
    return dice[top][front];
}
const int dx[4]={0,-1,1,0};
const int dy[4]={-1,0,0,1};
int main(void){
    while(1){
        int n;
        scanf("%d",&n);
        if(n==0) break;
        init();
        rep(i,n){
            int t, f;
            int starty=100,startx=100;
            scanf("%d%d", &t, &f);
            while(1){
                int dir[4];
                int direction=4;
                int max=3;
                dir[0]=7-f,dir[1]=left(t,f),dir[2]=7-dir[1],dir[3]=f;
                rep(j,4){
                    int tmpy=starty+dy[j],tmpx=startx+dx[j];
                    if((pos[starty][startx].h>pos[tmpy][tmpx].h)
                       && (dir[j]>max)){
                        direction=j;
                        max=dir[j];
                    }
                }
                //printf("%d:direction=%d t=%d f=%d\n",i,direction,t,f);
                if(max==3) break;
                else {
                    starty+=dy[direction],startx+=dx[direction];
                    switch (direction) {
                        case 0:f=7-t;break;
                        case 1:break;
                        case 2:break;
                        case 3:f=t;break;
                        default:break;
                    }
                    t=7-dir[direction];
                }
            }
            //if(starty==99&&startx==101)printf("clear\n");
            pos[starty][startx].h++;
            pos[starty][startx].num=t;
        }
        int a[6]={0};
        rep(i,200) rep(j,200) if(pos[i][j].num>0)a[pos[i][j].num-1]++;
        rep(i,6) printf("%d%c",a[i],i==5?'\n':' ');
    }
}

