#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <list>
#include <stdio.h>

using namespace std;
int dice[6][4]={
    2,4,5,3,//1
    1,3,6,4,//2
    1,5,6,2,//3
    1,2,6,5,//4
    1,4,6,3,//5
    4,2,3,5,//6
};

int next_dice[4][6]={
    3,0,2,4,5,1,
    4,1,0,3,5,2,
    1,5,2,0,4,3,
    2,1,5,3,0,4
};

void now_dice_out(int top, int fro, int now_dice[6]){
    now_dice[0]=top;
    now_dice[5]=7-top;
    now_dice[1]=fro;
    for(int i=0; i<4; i++){
        if(fro == dice[top-1][i]){
            now_dice[2]=dice[top-1][(i+1)%4];
            break;
        }
    }
    now_dice[3]=7-now_dice[1];
    now_dice[4]=7-now_dice[2];
};

void can_move_out(int x, int y, int dice_map_hig[200][200], int can_move[4]){
    if(dice_map_hig[x][y]>dice_map_hig[x][y-1]){
        can_move[0]=1;
    }
    if(dice_map_hig[x][y]>dice_map_hig[x-1][y]){
        can_move[1]=1;
    }
    if(dice_map_hig[x][y]>dice_map_hig[x][y+1]){
        can_move[2]=1;
    }
    if(dice_map_hig[x][y]>dice_map_hig[x+1][y]){
        can_move[3]=1;
    }
}

int move_dice(int can_move[4], int now_dice[6]){
    for(int i=1; i<=4; i++){
        if(now_dice[i]==6 && can_move[i-1]==1){
            return i;
        }
    }
    for(int i=1; i<=4; i++){
        if(now_dice[i]==5 && can_move[i-1]==1){
            return i;
        }
    }
    for(int i=1; i<=4; i++){
        if(now_dice[i]==4 && can_move[i-1]==1){
            return i;
        }
    }
    return -1;
}

int update_map(int dice_map_top[200][200], int dice_map_hig[200][200], int x,int y, int top, int fro){
    int now_dice[6]={0};
    now_dice_out(top, fro, now_dice);
    int can_move[4]={0};
    can_move_out(x,y,dice_map_hig,can_move);
    int compass =  move_dice(can_move, now_dice);
    if(compass==-1){
        dice_map_hig[x][y]++;
        dice_map_top[x][y]=top;
    }else{
        if(compass==1){
            y--;
            top=now_dice[3];
            fro=now_dice[0];
            update_map(dice_map_top, dice_map_hig, x, y, top, fro);
            
        }
        if(compass==2){
            x--;
            top=now_dice[4];
            fro=now_dice[1];
            update_map(dice_map_top, dice_map_hig, x, y, top, fro);
        }
        if(compass==3){
            y++;
            top=now_dice[1];
            fro=now_dice[5];
            update_map(dice_map_top, dice_map_hig, x, y, top, fro);
        }
        if(compass==4){
            x++;
            top=now_dice[2];
            fro=now_dice[1];
            update_map(dice_map_top, dice_map_hig, x, y, top, fro);
        }
    }
    return 0;
}




int main(){
    
    while(1){
        int num;
        cin>>num;
        if(num==0)break;
        int dice_map_top[200][200]={0};
        int dice_map_hig[200][200]={0};
        for(int i=0; i<num; i++){
            int top,fro;
            int x=100,y=100;
            cin>>top>>fro;
            update_map(dice_map_top, dice_map_hig, x, y, top, fro);
        }
        int dice_num[7]={0};
        for(int i=0; i<200; i++){
            for(int j=0; j<200; j++){
                dice_num[dice_map_top[i][j]]++;
            }
        }
        
        cout<<dice_num[1];
        for(int i=2; i<7; i++){
            cout<<" "<<dice_num[i];
        }
        cout<<endl;
    }
    
    
}

Measured memory_bytes: 1480