#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
typedef unsigned long long ll;

int d[24][6]={
    //top,down,front,back,left,right
    {1,6,3,4,2,5},
    {1,6,2,5,4,3},
    {1,6,5,2,3,4},
    {1,6,4,3,5,2},
    
    {4,3,1,6,2,5},
    {4,3,5,2,1,6},
    {4,3,6,1,5,2},
    {4,3,2,5,6,1},
    
    {6,1,3,4,5,2},
    {6,1,5,2,4,3},
    {6,1,4,3,2,5},
    {6,1,2,5,3,4},
    
    {3,4,1,6,5,2},
    {3,4,6,1,2,5},
    {3,4,5,2,6,1},
    {3,4,2,5,1,6},
    
    {2,5,1,6,3,4},
    {2,5,6,1,4,3},
    {2,5,3,4,6,1},
    {2,5,4,3,1,6},
    
    {5,2,1,6,4,3},
    {5,2,6,1,3,4},
    {5,2,4,3,6,1},
    {5,2,3,4,1,6}
};
//{4,3,2,5,6,1},
int mv[6][2]={
    {0,0},
    {0,0},
    {0,-1},
    {0,1},
    {-1,0},
    {1,0}
};
int cle[202][202];
int hig[202][202];
int coun[7];
bool roll(int x,int y,int i){
    int m=0,got=0;
    for(m=5;m>=2;m--){
       // cout<<"i: "<<i<<"    m:"<<m<<"     d[i][m]:"<<d[i][m]<<endl;
        if(d[i][m]==6&&hig[x+mv[m][0]][y+mv[m][1]]<hig[x][y]){
            got=1;
            break;
        }
    }
    if(got==0)
        for(m=5;m>=2;m--){
            if(d[i][m]==5&&hig[x+mv[m][0]][y+mv[m][1]]<hig[x][y]){
                got=1;
                break;
            }
        }
    if(got==0)
        for(m=5;m>=2;m--){
            if(d[i][m]==4){
                if(hig[x+mv[m][0]][y+mv[m][1]]<hig[x][y]){
                    got=1;
                    break;
                }
            }
        }
    
    if(got){
        if(hig[x+mv[m][0]][y+mv[m][1]]<hig[x][y]){
            int t=0,down=0,f=0,b=0,l=0,r=0;
            x+=mv[m][0];
            y+=mv[m][1];
            if(m==2){
                f   =d[i][0];
                b   =d[i][1];
                down=d[i][2];
                t   =d[i][3];
                l   =d[i][4];
                r   =d[i][5];
            }
            if(m==3){
                b   =d[i][0];
                f   =d[i][1];
                t   =d[i][2];
                down=d[i][3];
                l=d[i][4];
                r   =d[i][5];
            }
            if(m==4){
                l   =d[i][0];
                r   =d[i][1];
                f   =d[i][2];
                b   =d[i][3];
                down=d[i][4];
                t   =d[i][5];
            }
            if(m==5){
                r   =d[i][0];
                l   =d[i][1];
                f   =d[i][2];
                b   =d[i][3];
                t   =d[i][4];
                down=d[i][5];
            }
            int pattern=0;
            for(int fi=0;fi<24;fi++){
                if(d[fi][0]==t&&d[fi][1]==down&&d[fi][2]==f&&d[fi][3]==b&&d[fi][4]==l&&d[fi][5]==r){
                    pattern=fi;
                }
            }
            //cout<<"------ i: "<<i<<" ---- m: "<<m<<"  -----------t: "<<t<<"    down: "<<down<<"   f:"<<f<<"    b: "<<b<<"     l:"<<l<<"    r: "<<r<<endl;
            if(!roll(x,y,pattern)){
                cle[x][y]=t;
                hig[x][y]++;
             //   cout<<"x: "<<x<<"     y: "<<y<<"      t: "<<t<<endl;
            }
            
            return true;
        }
    }
    return false;
}

int main(){
    int n,t,f,i,x,y;
    while(cin>>n,n){
        memset(cle,0,sizeof(cle));
        memset(hig,0,sizeof(hig));
        memset(coun,0,sizeof(coun));
        x=101,y=101;
        cle[x][y]=1;
        while(n--){
            cin>>t>>f;
            for(i=0;i<24;i++){
                if(d[i][0]==t&&d[i][2]==f)
                    break;
            }
            if(!roll(x,y,i)){
                cle[x][y]=t;
                hig[x][y]++;
      //          cout<<"x: "<<x<<"     y: "<<y<<"      cle[x][y]: "<<cle[x][y]<<endl;
            }
        }
        for(int i=0;i<202;i++){
            for(int j=0;j<202;j++){
                if(cle[i][j]==0)continue;
        //        cout<<"cle[i][j]: "<<cle[i][j]<<endl;
                coun[cle[i][j]]++;
            }
        }
        for(int i=1;i<6;i++){
            cout<<coun[i]<<" ";
        }
        cout<<coun[6]<<endl;
    }
}

Measured memory_bytes: 1488