#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
/*
typedef int weight;
struct edge
{
	int from, to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};

typedef vector<edge> Edges;
typedef vector<Edges> Graph;
*/
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

struct Dice{
	int t, r, f;
	int top() { return t; }
	int bottom() { return 7 - t; }
	int right() { return r; }
	int left() { return 7 - r; }
	int front() { return f; }
	int back() { return 7 - f; }
	void toFront() { swap(f, t); t = 7 - t; }
	void toBack() { toFront(); toFront(); toFront(); }
	void toRight() { swap(t, r); t = 7 - t; }
	void toLeft() { toRight(); toRight(); toRight(); }
	void toClock() { swap(f, r); r = 7 - r; }
	void toConter() { toClock(); toClock(); toClock(); }
	int roll(int tt, int ff)
	{
		REP(i, 30)
		{
			if (i % 10 == 0) toRight();
			else if (i % 10 == 5) toFront();
			else toClock();
			if (tt == t && ff == f) return r;
		}
		return 0;
	}
};

int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<vector<vi>> fld(300, vector<vi>(300));
		REP(i, n)
		{
			int t, f;
			cin >> t >> f;
			Dice d;
			d.t = 1, d.f = 3, d.r = 5;
			while (!(d.t == t&&d.f == f))
			{
				int r = rand();
				if (r % 6 == 0) d.toFront();
				else if (r % 6 == 1) d.toBack();
				else if (r % 6 == 2) d.toRight();
				else if (r % 6 == 3) d.toLeft();
				else if (r % 6 == 4) d.toClock();
				else if (r % 6 == 5) d.toConter();
			}
			int tx = 150, ty = 150;
			bool update = true;
			while (update)
			{
				update = false;
				for (int i = 6; i >= 4; i--)
				{
					bool flag = true;
					if (d.right() == i&&fld[tx][ty].size() > fld[tx][ty + 1].size())
					{
						ty++;
						d.toRight();
						update = true;
						break;
					}
					else if (d.left() == i&&fld[tx][ty].size() > fld[tx][ty - 1].size())
					{
						ty--;
						d.toLeft();
						update = true;
						break;
					}
					else if (d.front() == i&&fld[tx][ty].size() > fld[tx + 1][ty].size())
					{
						tx++;
						d.toFront();
						update = true;
						break;
					}
					else if (d.back() == i&&fld[tx][ty].size() > fld[tx - 1][ty].size())
					{
						tx--;
						d.toBack();
						update = true;
						break;
					}
				}
			}
			fld[tx][ty].push_back(d.top());
		}
		int ans[6] = {};
		REP(i, 300)REP(j, 300)
		{
			if (fld[i][j].size() > 0) ans[fld[i][j].back()-1]++;
		}
		REP(i, 6) cout << ans[i] << (i == 5 ? '\n' : ' ');
	}
	return 0;
}

Measured memory_bytes: 3184