// Original C++ solution (slower):
#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]);

	}

}

// Optimized solution to the same problem (faster):
/*

 * Author: NomadThanatos

 * Created Time:  2012/7/17 14:06:59

 * File Name: C.cpp

 */

#include <iostream>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <cstdlib>

#include <algorithm>

#include <vector>

#include <queue>

#include <string>

#include <map>

#include <set>



using namespace std;



#define out(v) cerr << #v << ": " << (v) << endl

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



const int MAXINT = -1u>>1;

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

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

const int intod[] = {-1,1,0,-1,2,3};



const int spDice[6][3] = {{1,3,5},

						  {2,4,6},

						  {3,5,1},

						  {4,2,1},

						  {5,4,1},

						  {6,4,5}};



map< pair<int,int> , pair<int,int> > gra;



struct Dice {

	int roll[6];// 0 1 2 3 4 5 -> t f r at af ar;

	Dice() {};

	Dice(const int &t,const int &f) {

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

			roll[i] = spDice[t - 1][i];

			roll[i + 3] = 7 - spDice[t - 1][i];

		}

		while(roll[1] != f) {

			swap(roll[1],roll[2]);

			swap(roll[1],roll[4]);

			swap(roll[1],roll[5]);

		}

	}

	void rota(const int &d) {

		if (d == 0) {

			swap(roll[2],roll[3]);

			swap(roll[2],roll[5]);

			swap(roll[2],roll[0]);

		}

		if (d == 3) {

			swap(roll[2],roll[0]);

			swap(roll[2],roll[5]);

			swap(roll[2],roll[3]);

		}

		if (d == 1) {

			swap(roll[0],roll[1]);

			swap(roll[0],roll[3]);

			swap(roll[0],roll[4]);

		}

		if (d == 2) {

			swap(roll[0],roll[4]);

			swap(roll[0],roll[3]);

			swap(roll[0],roll[1]);

		}

	}

	Dice input() {

		int t,f;

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

		return Dice(t,f);

	}

	void output() {

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

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

		}

		printf("\n");

	}

}dice;



int sx,sy,hi;



bool canroll() {

	for(int t = 6 ; t > 3 ; t-- ) {

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

			if (dice.roll[i] == t && intod[i] != -1) {

				//printf("intod %d %d\n",t,intod[i]);

				int tx = sx + dx[intod[i]],ty = sy + dy[intod[i]];

				if (gra.find(make_pair(tx,ty)) == gra.end()) {

					dice.rota(intod[i]);

					sx = tx;sy = ty;

					return false;

				}

				else {

					if (hi > gra[make_pair(tx,ty)].first + 1) {

						hi = gra[make_pair(tx,ty)].first + 1;

						dice.rota(intod[i]);

						sx = tx;sy = ty;

						return true;

					}

				}

			}

		}

	}

	return false;

}



int hav[7];



int main() {

	int N;

	while(scanf("%d",&N) == 1 && N) {

		memset(hav,0,sizeof(hav));

		gra.clear();

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

			dice = dice.input();

			//dice.output();

			sx = 0;sy = 0;hi = 1;

			if (gra.find(make_pair(sx,sy)) == gra.end()) {

				gra[make_pair(sx,sy)] = make_pair(1,dice.roll[0]);

				//dice.output();

				//printf("%d %d %d\n",sx,sy,dice.roll[0]);

			}

			else {

				hi = gra[make_pair(sx,sy)].first + 1;

				//printf("-- %d %d\n",i,hi);

				while(canroll()) {

					//printf("roro\n");

					//printf("%d %d\n",sx,sy);

				};

				if (gra.find(make_pair(sx,sy)) == gra.end()) {

					gra[make_pair(sx,sy)] = make_pair(1,dice.roll[0]);

					//dice.output();

					//printf("%d %d %d\n",sx,sy,dice.roll[0]);

				}

				else {

					//dice.output();

					//printf("%d %d %d\n",sx,sy,dice.roll[0]);

					gra[make_pair(sx,sy)] = make_pair(gra[make_pair(sx,sy)].first + 1,dice.roll[0]);

				}

			}

			//for(int i = 0 ; i < 6 ; i++) {

				//printf("%d ",dice.roll[i]);

			//}

			//printf("\n");

		}

		for(map< pair<int,int> , pair<int,int> > :: iterator it = gra.begin() ; it != gra.end() ; it++) {

			//sx = (it->first).first;

			//sy = (it->first).second;

			//hi = (it->second).first;

			//int fa = (it->second).second;

			//printf("(%d,%d) = %d %d\n",sx,sy,hi,fa);

			hav[(it->second).second]++;

		}

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

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

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

		}

		printf("\n");

	}

    return 0;

}

// Fastest known solution for this problem: