// 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.1518943489198543x):
#include <bits/stdc++.h>

#define int long long

// using ii = pair<int, int>;

using namespace std;



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

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

vector<int> tbl[] = {

    {},

    {4, 2, 3, 5},

    {4, 6, 3, 1},

    {1, 2, 6, 5},

    {6, 2, 1, 5},

    {4, 1, 3, 6},

    {4, 5, 3, 2},

};



void solve() {

    int n; cin >> n;

    if (n == 0) exit(0);

    vector<int> t(n), f(n);

    for (int i = 0; i < n; i++) cin >> t[i] >> f[i];



    vector<vector<int>> num(100, vector<int>(100));

    vector<vector<int>> top(100, vector<int>(100));

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

        int x = 50, y = 50;

        int ct = t[i], cf = f[i];

        while (1) {

            // cout << x << " " << y << endl;

            int face = find(tbl[ct].begin(), tbl[ct].end(), cf) - tbl[ct].begin();

            bool no = true;

            for (int k = 6; k >= 4; k--) {

                int tmp = find(tbl[ct].begin(), tbl[ct].end(), k) - tbl[ct].begin();

                if (tmp >= 4) continue;

                int dif = (tmp - face + 4) % 4;

                int nx = x + dx[dif], ny = y + dy[dif];

                if (num[x][y] > num[nx][ny]) {

                    x = nx, y = ny;

                    if (dif == 0) cf = ct;

                    if (dif == 2) cf = 7 - ct;

                    ct = tbl[ct][(tmp + 2) % 4];

                    no = false;

                    break;

                }

            }

            if (no) break;

        }

        num[x][y]++;

        top[x][y] = ct;

    }



    vector<int> ans(7);

    for (int i = 0; i < 100; i++) {

        for (int j = 0; j < 100; j++) {

            ans[top[i][j]]++;

        }

    }

    for (int i = 1; i < 7; i++) {

        cout << ans[i] << (i == 6 ? "" : " ");

    }

    cout << endl;

}



signed main() {

    while (1) solve();

}