#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <map>
using namespace std;

#define REP(i, b, e) for (int i = (b); i < (e); i++)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, b, e) for (int i = (b); i <= (e); i++)
#define repi(i, n) REPI(i, 0, n)

#define dump(x) //cout << #x << ":" << x << endl
#define dumpstr(s) //cout << s << endl;

typedef enum {
	TOP,
	BOTTOM,
	FRONT,
	BACK,
	RIGHT,
	LEFT
} Surface;

class Dice
{
private:
	int surface[6];
public:
	Dice() {
		surface[TOP] = 1;
		surface[FRONT] = 2;
		surface[RIGHT] = 3;
		surface[BOTTOM] = 6;
		surface[BACK] = 5;
		surface[LEFT] = 4;
	}

	void rotate(Surface a, Surface b, Surface c, Surface d)
	{
		int buf = surface[a];
		surface[a] = surface[b];
		surface[b] = surface[c];
		surface[c] = surface[d];
		surface[d] = buf;
	}

	void north()	{ rotate(TOP, FRONT, BOTTOM, BACK); }
	void east()		{ rotate(TOP, LEFT, BOTTOM, RIGHT); }
	void west()		{ rotate(TOP, RIGHT, BOTTOM, LEFT); }
	void south()	{ rotate(TOP, BACK, BOTTOM, FRONT); }
	void right()	{ rotate(FRONT, RIGHT, BACK, LEFT); }
	void left()		{ rotate(FRONT, LEFT, BACK, RIGHT); }

	void set(int top, int front)
	{
		if (!(top == 1 || top == 2 || top == 5 || top == 6)) {
			right();
		}
		while(surface[TOP] != top)
			north();
		while(surface[FRONT] != front)
			right();
	}

	int operator[](Surface idx)
	{
		return surface[idx];
	}
};

#define MAX 10
#define OFFSET 5

int n;
int brd[MAX][MAX];
int dice_brd[MAX][MAX];

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

void doit(int y, int x, Dice &dice)
{
	dump(x);
	dump(y);
	if (brd[y][x] == 0) {
		brd[y][x]++;
		dice_brd[y][x] = dice[TOP];
		return;
	}

	vector< pair<int, Surface> > vs;
	vs.push_back(make_pair(dice[FRONT], FRONT));
	vs.push_back(make_pair(dice[RIGHT], RIGHT));
	vs.push_back(make_pair(dice[LEFT], LEFT));
	vs.push_back(make_pair(dice[BACK], BACK));
	sort(vs.begin(), vs.end());
	reverse(vs.begin(), vs.end());

	rep(i, 4) {
		int num; Surface sur;
		num = vs[i].first, sur = vs[i].second;
		if (!(num >= 4)) continue;

		int nx, ny;
		nx = x + dx[mapping[sur]];
		ny = y + dy[mapping[sur]];
		dump(nx);
		dump(ny);
		dump(brd[y][x]);
		dump(brd[ny][nx]);
		bool f = brd[y][x] > brd[ny][nx];
		dump(f);
		if (brd[y][x] > brd[ny][nx]) {
			if (sur == FRONT) {
				dice.south();
			} else if (sur == RIGHT) {
				dice.east();
			} else if (sur == LEFT) {
				dice.west();
			} else if (sur == BACK) {
				dice.north();
			}
			doit(ny, nx, dice);
			return;
		}
	}
	brd[y][x]++;
	dice_brd[y][x] = dice[TOP];
}

void print_brd()
{
	rep(j, MAX) {
		rep(i, MAX) {
			if (dice_brd[j][i] == 0)
				cout << '.';
			else
				cout << dice_brd[j][i];
		}
		cout << endl;
	}
	rep(j, MAX) {
		rep(i, MAX) {
			cout << brd[j][i];
		}
		cout << endl;
	}
}

int main()
{
	mapping[FRONT] = 0;
	mapping[RIGHT] = 1;
	mapping[LEFT] = 2;
	mapping[BACK] = 3;
	while (cin >> n, n) {
		memset(brd, 0, sizeof(brd));
		memset(dice_brd, 0, sizeof(dice_brd));
		rep(k, n) {
			int t, f;
			Dice dice;

			cin >> t >> f;
			dice.set(t, f);
			dump(dice[TOP]);
			doit(OFFSET, OFFSET, dice);
			//print_brd();
		}
		int cnts[10];
		memset(cnts, 0, sizeof(cnts));
		rep(j, MAX) {
			rep(i, MAX) {
				cnts[dice_brd[j][i]]++;
			}
		}
		REPI(i, 1, 6) {
			printf("%d%c", cnts[i], (i==6?'\n':' '));
		}
	}
	return 0;
}

Measured memory_bytes: 1176