/*
 * 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;
}

Measured memory_bytes: 0