/*
 * Copyright (C) 2012 Hiroyasu Kamo
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * ACM-ICPC 2012 Japan Domestic Contest
 *  Problem C  Biased Dice
 *
 *	Author: Hiroyasu Kamo <wd@ics.nara-wu.ac.jp>
 */

#include <utility>
#include <vector>
#include <map>
#include <array>
#include <iostream>

using std::vector;
using std::map;
using std::array;
using std::cin;
using std::cout;

class board {
private:
	struct die {
		int	faces[3][2];
		void	roll(int, int);
	};
	map<array<int, 2>, vector<die> >	piles;
	const die	make_die(int, int);
public:
	board() {}
	void	drop_die(int, int);
	map<int, int>	get_casts();
};

const array<int, 2>
adjacency(const array<int, 2> &pos, int axis, int dir)
{
	array<int, 2>	pos1 = pos;
	pos1[axis] -= dir * 2 - 1;
	return pos1;
}

const board::die
board::make_die(int t, int f)
{
	die	d;
	d.faces[2][0] = t;
	d.faces[2][1] = 7 - t;
	d.faces[0][0] = f;
	d.faces[0][1] = 7 - f;
	bool	parity = false;
	if (t >= 4) {
		t = 7 - t;
		parity ^= true;
	}
	if (f >= 4) {
		f = 7 - f;
		parity ^= true;
	}
	const int	r = 6 - t - f;
	parity ^= (3 + t - f) % 3 != 1;
	d.faces[1][parity] = r;
	d.faces[1][!parity] = 7 - r;
	return d;
}

void
board::die::roll(int axis, int dir)
{
	const int	temp = faces[axis][dir];
	faces[axis][dir] = faces[2][0];
	faces[2][0] = faces[axis][dir ^ 1];
	faces[axis][dir ^ 1] = faces[2][1];
	faces[2][1] = temp;
}

void
board::drop_die(int t, int f)
{
	array<int, 2>	pos = {{0, 0}};
	piles[pos].push_back(make_die(t, f));
next:
	for (int n = 6; n > 3; n --) {
		for (int axis = 0; axis < 2; axis ++) {
			for (int dir = 0; dir < 2; dir ++) {
				if (piles[pos].back().faces[axis][dir] == n) {
					const array<int, 2>	pos1 = adjacency(pos, axis, dir);
					if (piles[pos].size() > piles[pos1].size() + 1) {
						piles[pos1].push_back(piles[pos].back());
						piles[pos].pop_back();
						piles[pos1].back().roll(axis, dir);
						pos = pos1;
						goto next;
					}
				}
			}
		}
	}
}

map<int, int>
board::get_casts()
{
	map<int, int>	casts;
	for (map<array<int, 2>, vector<die> >::iterator p = piles.begin();
	     p != piles.end(); ++ p) {
		if (!p->second.empty()) {
			++ casts[p->second.back().faces[2][0]];
		}
	}
	return std::move(casts);
}

int
main()
{
	for (int n; cin >> n && n > 0; ) {
		board	bd;
		for (int i = 0; i < n; i ++) {
			int	t, f;
			cin >> t >> f;
			bd.drop_die(t, f);
		}
		map<int, int>	casts = bd.get_casts();
		cout << casts[1] << " "
		     << casts[2] << " "
		     << casts[3] << " "
		     << casts[4] << " "
		     << casts[5] << " "
		     << casts[6] << "\n";
	}
	return 0;
}
