#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<limits>
#include<iomanip>
using namespace std;


class sai{
public:
    int ue,sita,mae,ushiro,migi,hidari;
    
    sai(int top=1,int front=3,int ued=1,int sitad=6,int maed=3,int ushirod=4,int migid=5,int hidarid=2):ue(ued),sita(sitad),mae(maed),ushiro(ushirod),migi(migid),hidari(hidarid) {
        
        for(int i=0;i<=6;i++){
            if(ue==top && mae==front){break;}
            for(int t=0;t<8;t++){
                move(5);
                if(ue==top && mae==front){break;}
            }
            if(ue==top && mae==front){break;}
            if(i<4){move(1);}
            if(i==4){move(2);}
            if(i==5){move(2); move(2);}
        }
        if(!(ue==top && mae==front)){cout<<top<<" : "<<ue<<"   "<<front<<" : "<<mae<<endl;}
        assert(ue==top && mae==front);
    }
    
    int move(int i){
        int ued=ue,sitad=sita,maed=mae,ushirod=ushiro,migid=migi,hidarid=hidari;
        if(i==1){
            ushiro=ued;
            ue=maed;
            mae=sitad;
            sita=ushirod;
        }
        if(i==2){
            migi=ued;
            ue=hidarid;
            hidari=sitad;
            sita=migid;
        }
        if(i==3){
            ushiro=sitad;
            ue=ushirod;
            mae=ued;
            sita=maed;
        }
        if(i==4){
            migi=sitad;
            ue=migid;
            hidari=ued;
            sita=hidarid;
        }
        if(i==5){
            migi=maed;
            mae=hidarid;
            hidari=ushirod;
            ushiro=migid;
        }
        return ue;
    }
    
    int where(int me){
        if(ue==me){return 0;}
        if(mae==me){return 3;}
        if(ushiro==me){return 1;}
        if(migi==me){return 2;}
        if(hidari==me){return 4;}
        return 0;
    }
    
    
};


stack<int> me[200][200];
int h[200][200];

int main(){
    while(1){
        for(int i=0;i<200;i++){
            for(int t=0;t<200;t++){
                h[i][t]=0;
                me[i][t].push(0);
            }
        }
        int n;
        cin>>n;
        if(n==0){break;}
        for(int i=0;i<n;i++){
            int x=100,y=100;
            int top,front;
            cin>>top>>front;
            h[x][y]++;
            me[x][y].push(top);
            sai saikoro(top,front);
            while(1){
                int to=0;
                bool done=false;
                for(int t=6;t>=4;t--){
                    to=saikoro.where(t);
                    if(to==0){continue;}
                    if(to==1 && h[x][y]>h[x][y+1]+1){me[x][y].pop(); h[x][y]--; y++; h[x][y]++; me[x][y].push(saikoro.move(to)); done=true; break;}
                    if(to==2 && h[x][y]>h[x+1][y]+1){me[x][y].pop(); h[x][y]--; x++; h[x][y]++; me[x][y].push(saikoro.move(to)); done=true; break;}
                    if(to==3 && h[x][y]>h[x][y-1]+1){me[x][y].pop(); h[x][y]--; y--; h[x][y]++;  me[x][y].push(saikoro.move(to)); done=true; break;}
                    if(to==4 && h[x][y]>h[x-1][y]+1){me[x][y].pop(); h[x][y]--; x--; h[x][y]++;  me[x][y].push(saikoro.move(to)); done=true; break;}
                }
                if(!done){break;}
            }
            
            
        }
        int ans[7]={};
        for(int i=0;i<200;i++){
            for(int t=0;t<200;t++){
                ans[me[i][t].top()]++;
            }
        }
        for(int i=1;i<=6;i++){
            cout<<ans[i];
            if(i!=6){cout<<" ";}
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 50504