// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



struct Dice{

private:

	static const int _roll[4][6], _turn[2][6];

public:

	vector<int> value;

	// 1-6 : top, near, right, left, far, bottom 



	Dice(){

		value.resize(6);

		for (int i = 0; i < 6; ++i) value[i] = i;

	}



	void roll(int dir){ // N, E, W, S

		vector<int> nxt(6);

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

			nxt[i] = value[_roll[dir][i]];

		}

		value = nxt;

	}



	void turn(int dir){ // L, R

		vector<int> nxt(6);

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

			nxt[i] = value[_turn[dir][i]];

		}

		value = nxt;

	}



	int &operator[](int i){

		return value[i];

	}

};



const int Dice::_roll[4][6] = {

	{ 1, 5, 2, 3, 0, 4 }, // North

	{ 3, 1, 0, 5, 4, 2 }, // East

	{ 2, 1, 5, 0, 4, 3 }, // West

	{ 4, 0, 2, 3, 5, 1 }, // South

};



const int Dice::_turn[2][6] = {

	{ 0, 3, 1, 4, 2, 5 }, // Left

	{ 0, 2, 4, 1, 3, 5 }, // Right

};



typedef pair<int, int> P;



int main(){	

	int n;



	int rdir[] = { 0, 3, 1, 2, 0 };

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

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

	while (cin >> n, n){

		P field[200][200];



		while (n--){

			int t, f;

			cin >> t >> f;

			Dice d;

			for (int i = 0; i < 6; ++i) d[i] = i + 1;

			if (d[2] == t || d[3] == t) d.turn(0);

			while (d[0] != t) d.roll(0);

			while (d[1] != f) d.turn(0);



			P pos = make_pair(100, 100);

			while (1){

				P dir = make_pair(-1, -1);

				for (int i = 1; i <= 4; ++i){

					int nx = pos.first + dx[rdir[i]], ny = pos.second + dy[rdir[i]];

					if(d[i] >= 4 && field[pos.second][pos.first].first > field[ny][nx].first) dir = max(dir, make_pair(d[i], rdir[i]));

				}

				if (dir.second < 0) break;

				d.roll(dir.second);

				pos.first += dx[dir.second];

				pos.second += dy[dir.second];

			}

			++field[pos.second][pos.first].first;

			field[pos.second][pos.first].second = d[0];

		}

		int cnt[7] = {};

		for (int i = 0; i < 200; ++i)for (int j = 0; j < 200; ++j){

			++cnt[field[i][j].second];

		}

		for (int i = 0; i < 6; i++) cout << (i ? " " : "") << cnt[i + 1];

		cout << endl;

	}



	return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



struct Dice{

private:

	static const int _roll[4][6], _turn[2][6];

public:

	vector<int> value;

	// 1-6 : top, near, right, left, far, bottom 



	Dice(){

		value.resize(6);

		for (int i = 0; i < 6; ++i) value[i] = i;

	}



	void roll(int dir){ // N, E, W, S

		vector<int> nxt(6);

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

			nxt[i] = value[_roll[dir][i]];

		}

		value = nxt;

	}



	void turn(int dir){ // L, R

		vector<int> nxt(6);

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

			nxt[i] = value[_turn[dir][i]];

		}

		value = nxt;

	}



	int &operator[](int i){

		return value[i];

	}

};



const int Dice::_roll[4][6] = {

	{ 1, 5, 2, 3, 0, 4 }, // North

	{ 3, 1, 0, 5, 4, 2 }, // East

	{ 2, 1, 5, 0, 4, 3 }, // West

	{ 4, 0, 2, 3, 5, 1 }, // South

};



const int Dice::_turn[2][6] = {

	{ 0, 3, 1, 4, 2, 5 }, // Left

	{ 0, 2, 4, 1, 3, 5 }, // Right

};



typedef pair<int, int> P;



const int N = 30;



int main(){	

	int n;



	int rdir[] = { 0, 3, 1, 2, 0 };

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

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

	while (cin >> n, n){

		P field[N][N];



		while (n--){

			int t, f;

			cin >> t >> f;

			Dice d;

			for (int i = 0; i < 6; ++i) d[i] = i + 1;

			if (d[2] == t || d[3] == t) d.turn(0);

			while (d[0] != t) d.roll(0);

			while (d[1] != f) d.turn(0);



			P pos = make_pair(N/2, N/2);

			while (1){

				P dir = make_pair(-1, -1);

				for (int i = 1; i <= 4; ++i){

					int nx = pos.first + dx[rdir[i]], ny = pos.second + dy[rdir[i]];

					if(d[i] >= 4 && field[pos.second][pos.first].first > field[ny][nx].first) dir = max(dir, make_pair(d[i], rdir[i]));

				}

				if (dir.second < 0) break;

				d.roll(dir.second);

				pos.first += dx[dir.second];

				pos.second += dy[dir.second];

			}

			++field[pos.second][pos.first].first;

			field[pos.second][pos.first].second = d[0];

		}

		int cnt[7] = {};

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

			++cnt[field[i][j].second];

		}

		for (int i = 0; i < 6; i++) cout << (i ? " " : "") << cnt[i + 1];

		cout << endl;

	}



	return 0;

}

// Fastest known solution for this problem: