// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <vector>

#include <deque>

#include <cmath>

#include <algorithm>

#include <iostream>

using namespace std;



struct{

	int h;

	int t;

}tu[200][200];



int a[6][6][8]={

	0,0,0,0,0,0,0,0,

	1,2,4,5,3,6,3,2,

	1,3,2,4,5,6,4,3,

	1,4,5,3,2,6,2,1,

	1,5,3,2,4,6,1,4,

	0,0,0,0,0,0,0,0,



	2,1,3,6,4,5,3,4,

	0,0,0,0,0,0,0,0,

	2,3,6,4,1,5,2,3,

	2,4,1,3,6,5,4,1,

	0,0,0,0,0,0,0,0,

	2,6,4,1,3,5,1,2,



	3,1,5,6,2,4,3,2,

	3,2,1,5,6,4,4,3,

	0,0,0,0,0,0,0,0,

	0,0,0,0,0,0,0,0,

	3,5,6,2,1,4,2,1,

	3,6,2,1,5,4,1,4,





	4,1,2,6,5,3,3,4,

	4,2,6,5,1,3,2,3,

	0,0,0,0,0,0,0,0,

	0,0,0,0,0,0,0,0,

	4,5,1,2,6,3,4,1,

	4,6,5,1,2,3,1,2,



	5,1,4,6,3,2,3,2,

	0,0,0,0,0,0,0,0,

	5,3,1,4,6,2,4,3,

	5,4,6,3,1,2,2,1,

	0,0,0,0,0,0,0,0,

	5,6,3,1,4,2,1,4,



	0,0,0,0,0,0,0,0,

	6,2,3,5,4,1,3,4,

	6,3,5,4,2,1,2,3,

	6,4,2,3,5,1,4,1,

	6,5,4,2,3,1,1,2,

	0,0,0,0,0,0,0,0,

};







int main()

{

	int n,m,i,j,k,t,f;

	while(scanf("%d", &n) && n){

		memset(tu,0,sizeof(tu));

		while(n--)

		{

			scanf("%d %d",&t,&f);

			i=100;j=100;

			while(1){



				if(a[t-1][f-1][6]==1){

					if( tu[i][j].h > tu[i][j-1].h ){

						int temp = a[t-1][f-1][3];

						f = t; //cout<<"*1*";

						t=temp;

						j = j-1; continue;

					}

				}



				if(a[t-1][f-1][6]==2){

					if( tu[i][j].h > tu[i-1][j].h ){

						int temp = a[t-1][f-1][4];

						f = f;

						t=temp; //cout<<"**"<<i<<" "<<j<<" "<<tu[i][j].h<<" "<<tu[i-1][j].h<<"> ";

						i = i-1; continue;

					}

				}



				if(a[t-1][f-1][6]==3){

					if( tu[i][j].h > tu[i][j+1].h ){

						int temp = a[t-1][f-1][1];

						f =  a[t-1][f-1][5];

						t=temp; //cout<<"*3*";

						j = j+1; continue;

					}

				}



				if(a[t-1][f-1][6]==4){

					if( tu[i][j].h > tu[i+1][j].h ){

						int temp = a[t-1][f-1][2];

						f = f; //cout<<"*4*";

						t=temp; //cout<<"?";

						i = i+1; continue;

					}

				}





				if(a[t-1][f-1][7]==1){

					if( tu[i][j].h > tu[i][j-1].h ){

						int temp = a[t-1][f-1][3];

						f = t;

						t=temp; //cout<<"#1#";

						j = j-1; continue;

					}

				}



				if(a[t-1][f-1][7]==2){

					if( tu[i][j].h > tu[i-1][j].h ){

						int temp = a[t-1][f-1][4];

						f = f;

						t=temp;//cout<<"#2#";

						i = i-1; continue;

					}

				}



				if(a[t-1][f-1][7]==3){

					if( tu[i][j].h > tu[i][j+1].h ){

						int temp = a[t-1][f-1][1];

						f =  a[t-1][f-1][5];

						t=temp;//cout<<"#3#"<<i<<" "<<j<<" "<<tu[i][j].h<<" "<<tu[i][j+1].h<<"> "<<endl;;

						j = j+1; continue;

					}

				}



				if(a[t-1][f-1][7]==4){

					if( tu[i][j].h > tu[i+1][j].h ){

						int temp = a[t-1][f-1][2];

						f = f;

						t=temp;//cout<<"#4#";

						i = i+1; continue;

					}

				}



				tu[i][j].h++;

				tu[i][j].t=t;

				break;

			}

			//int c[8]={0};

			//for( i = 0; i < 200; i++ )

			//	for( j = 0; j < 200; j ++ )

			//	{

			//		c[tu[i][j].t]++;

			//		if(tu[i][j].t) cout<<tu[i][j].h<<" "<<tu[i][j].t<<" "<<i<<" "<<j<<endl;

			//	}

			//	for(i = 1; i < 6; i++)

			//		printf("%d ",c[i]);

			//	printf("%d\n",c[6]);

		}

		int c[8]={0};

		for( i = 0; i < 200; i++ )

			for( j = 0; j < 200; j ++ )

				c[tu[i][j].t]++;

		for(i = 1; i < 6; i++){

			printf("%d ",c[i]);

		}

		printf("%d\n",c[6]);

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.1520411654575353x):
/*

 * Author:heroming

 * File:heroming.cpp

 * Time:2012-7-17 13:29:51

 */

#include <iostream>

#include <cstdio>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

using namespace std;



#define SZ(v) ((int)(v).size())

const int MAXN = 30, MID = 15;

const int dx[] = {1, 0, -1, 0};

const int dy[] = {0, -1, 0, 1};

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

const int LEFT[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}};



int n, t, f, A[7], B[7];

int P[MAXN][MAXN][MAXN][2];

int T[MAXN][MAXN];



void fall(int x, int y, int z, int top, int front)

{

        int ff = front;

        memset(B, -1, sizeof(B));

        for (int k = 0; k < 4; ++ k)

        {

                if (ff >= 4 && ff <= 6)

                        B[ff] = k;

                ff = LEFT[top][ff];

        }

        for (int i = 6; i >= 4; -- i)

        {

                if (B[i] == -1)

                        continue;

                int k = B[i];

                int a = x + dx[k];

                int b = y + dy[k];

                if (T[a][b] < z)

                {

                        int tt;

                        if (k == 0)

                                tt = top;

                        else if (k == 2)

                                tt = OPPO[top];

                        else

                                tt = front;

                        fall(a, b, T[a][b], OPPO[i], tt);

                        return;

                }

        }



        P[x][y][z + 1][0] = top;

        P[x][y][z + 1][1] = front;

        ++ T[x][y];

}



int main()

{

        while (scanf("%d", &n) != EOF && n)

        {

                memset(P, 0, sizeof(P));

                memset(T, 0, sizeof(T));

                for (int i = 0; i < n; ++ i)

                {

                        scanf("%d%d", &t, &f);

                        fall(MID, MID, T[MID][MID], t, f);

                }

                memset(A, 0, sizeof(A));

                for (int i = 0; i < MAXN; ++ i)

                        for (int j = 0; j < MAXN; ++ j)

                                ++ A[P[i][j][T[i][j]][0]];

                printf("%d", A[1]);

                for (int i = 2; i <= 6; ++ i)

                        printf(" %d", A[i]);

                printf("\n");

        }

        return 0;

}