#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int dice[6][6] = { {-1,2,4,1,3,-1}, {3,-1,0,5,-1,2}, {1,5,-1,-1,0,4}, {4,0,-1,-1,5,1}, {2,-1,5,0,-1,3}, {-1,3,1,4,2,-1} };

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	while (cin >> N, N) {
		vector<vector<int>>num(2 * N + 1, vector<int>(2 * N + 1));
		vector<vector<int>>tp(2 * N + 1, vector<int>(2 * N + 1));
		for (int loop = 0; loop < N; loop++) {
			int a, b;
			cin >> a >> b;
			a--, b--;
			int c = dice[a][b];
			int y = N, x = N;
			while (1) {
				if (b == 5) {
					if (num[y][x] > num[y + 1][x]) {
						y++;
						swap(a, b);
						a = 5 - a;
						continue;
					}
				}
				if (b == 0) {
					if (num[y][x] > num[y - 1][x]) {
						y--;
						swap(a, b);
						b = 5 - b;
						continue;
					}
				}
				if (c == 5) {
					if (num[y][x] > num[y][x + 1]) {
						x++;
						swap(a, c);
						a = 5 - a;
						continue;
					}
				}
				if (c == 0) {
					if (num[y][x] > num[y][x - 1]) {
						x--;
						swap(a, c);
						c = 5 - c;
						continue;
					}
				}
				if (b == 4) {
					if (num[y][x] > num[y + 1][x]) {
						y++;
						swap(a, b);
						a = 5 - a;
						continue;
					}
				}
				if (b == 1) {
					if (num[y][x] > num[y - 1][x]) {
						y--;
						swap(a, b);
						b = 5 - b;
						continue;
					}
				}
				if (c == 4) {
					if (num[y][x] > num[y][x + 1]) {
						x++;
						swap(a, c);
						a = 5 - a;
						continue;
					}
				}
				if (c == 1) {
					if (num[y][x] > num[y][x - 1]) {
						x--;
						swap(a, c);
						c = 5 - c;
						continue;
					}
				}
				if (b == 3) {
					if (num[y][x] > num[y + 1][x]) {
						y++;
						swap(a, b);
						a = 5 - a;
						continue;
					}
				}
				if (b == 2) {
					if (num[y][x] > num[y - 1][x]) {
						y--;
						swap(a, b);
						b = 5 - b;
						continue;
					}
				}
				if (c == 3) {
					if (num[y][x] > num[y][x + 1]) {
						x++;
						swap(a, c);
						a = 5 - a;
						continue;
					}
				}
				if (c == 2) {
					if (num[y][x] > num[y][x - 1]) {
						x--;
						swap(a, c);
						c = 5 - c;
						continue;
					}
				}
				break;
			}
			num[y][x]++;
			//cout <<"y x "<< y << " " << x << endl;
			tp[y][x] = a;
		}
		vector<int>ans(6);
		for (int i = 0; i <= 2 * N; i++) {
			for (int j = 0; j <= 2 * N; j++) {
				if (num[i][j])ans[tp[i][j]]++;
			}
		}
		for (int i = 0; i < 6; i++) {
			if (i)cout << " ";
			cout << ans[i];
		}
		cout << endl;
	}
	return 0;
}
