#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
int hight[200][200]={};
int dice[6];
int number[200][200]={};
int X,Y,front,top;
void make_dice(int front,int top){//dice={上,前,左,奥,右,下}
    if(front==1&&top==3){
        int dice1[]={3,1,5,6,2,4};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==1&&top==5){
        int dice1[]={5,1,4,6,3,2};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==1&&top==2){
        int dice1[]={2,1,3,6,4,5};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==1&&top==4){
        int dice1[]={4,1,2,6,5,3};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==2&&top==4){
        int dice1[]={4,2,6,5,1,3};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==2&&top==1){
        int dice1[]={1,2,4,5,3,6};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==2&&top==6){
        int dice1[]={6,2,3,5,4,1};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==2&&top==3){
        int dice1[]={3,2,1,5,6,4};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==3&&top==2){
        int dice1[]={2,3,6,4,1,5};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==3&&top==6){
        int dice1[]={6,3,5,4,2,1};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==3&&top==1){
        int dice1[]={1,3,2,4,5,6};
        for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==3&&top==5){
        int dice1[]={5,3,1,4,6,2};
		for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==4&&top==5){
        int dice1[]={5,4,6,3,1,2};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==4&&top==1){
		int dice1[]={1,4,5,3,2,6};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==4&&top==6){
		int dice1[]={6,4,2,3,5,1};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==4&&top==2){
		int dice1[]={2,4,1,3,6,5};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==5&&top==3){
		int dice1[]={3,5,6,2,1,4};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==5&&top==6){
		int dice1[]={6,5,4,2,3,1};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==5&&top==1){
		int dice1[]={1,5,3,2,4,6};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==5&&top==4){
		int dice1[]={4,5,1,2,6,3};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==6&&top==4){
		int dice1[]={4,6,5,1,2,3};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==6&&top==2){
		int dice1[]={2,6,4,1,3,5};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==6&&top==5){
		int dice1[]={5,6,3,1,4,2};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
    if(front==6&&top==3){
		int dice1[]={3,6,2,1,5,4};
    	for(int i=0;i<6;i++) dice[i] = dice1[i];
    }
}
void rotate(int place){
    if(place==1){
		    front = dice[0];
			top = dice[3];
	}
    else if(place==2)   top = dice[4];
    else if(place==3){
		   front=dice[5];
		   top=dice[1];
	}
    else if(place==4)   top = dice[2];
}
bool check(int place){ //転がれるかどうかのチェック
    int x=X+100,y=Y+100;
    if(place==1){   //手前
        if(hight[y+1][x]<hight[y][x]){
            Y++;
              return true;
        }
    }
    else if(place==2){  //左
        if(hight[y][x-1]<hight[y][x]){
            X--;
            return true;
        }
    }
    else if(place==3){  //奥
        if(hight[y-1][x]<hight[y][x]){
            Y--;
            return true;
        }
    }
    else if(place==4){  //右
        if(hight[y][x+1]<hight[y][x]){
            X++;
            return true;
        }
    }
	return false;
}
int stop(){
    int x=X+100,y=Y+100;
    hight[y][x]++;
    number[y][x]=top;
}
int main(){
	while(1){
		for(int i=0;i<200;i++){
			for(int j=0;j<200;j++){
				hight[i][j]=0;
				number[i][j]=0;
			}
		}
		int n,ans[7]={};
		cin >> n;
		if(!n)	break;
		for(int i=0;i<n;i++){
			X=0,Y=0;
			cin >> top >> front;
			make_dice(front,top); //サイコロのマス目を埋める
			while(1){
				bool rt_flag=false;//回転が行われたかどうか判定
				vector<int> vc(5);
				vc[0]=0;
				for(int i=1;i<5;i++) vc[i] = dice[i];
				sort(vc.begin(),vc.end());//回転可能部分の番号
				for(int i=4;(i>=3&&!rt_flag);i--){
					for(int j=1;(j<5&&!rt_flag);j++){
						if(vc[i]==dice[j]){
							if(check(j)){
								rotate(j);
								make_dice(front,top);
								rt_flag=true;
								break;
							}
						}
					}
				}
				if(!rt_flag){
					stop();
					break;
				}
			}
		}
		for(int i=0;i<200;i++){
			for(int j=0;j<200;j++)   ans[number[i][j]]++;
		}
		cout << ans[1];
		for(int i=2;i<=6;i++)    cout << ' ' << ans[i];
		cout << endl;
		
	}
}


Measured memory_bytes: 3320