#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<list>
#include<fstream>

#define REP(i,n) for(int i = 0; i < n ; ++i)
#define LL long long 
using namespace std;

struct D{
	int x, y, top, front;
};

D dice[7][7][2];

int table[100][300][300];

bool table_b[300][300];

int dice_num[6];

void func(int top, int front, int x, int y, int h)
{
	if (h == 0){
		table[0][x][y] = top;
		return;
	}
	if (table[h - 1][x][y] == 0){
		func(top, front, x, y, h - 1);
		return;
	}
	auto a = dice[top][front][0];

	if (table[h-1][x + a.x][y + a.y] == 0){
		func(a.top, a.front, x + a.x, y + a.y, h - 1);
		return;
	}

	a = dice[top][front][1];

	if (table[h-1][x + a.x][y + a.y] == 0){
		func(a.top, a.front, x + a.x, y + a.y, h - 1);
		return;
	}

	table[h][x][y] = top;
	
	return;
}

int main()
{
	//ifstream cin("Ain.txt");
//	ofstream cout("Aout.txt");
	dice[1][2][0] = { 1, 0, 2, 6 };
	dice[1][2][1] = { 0, -1, 3, 2 };
	dice[1][3][0] = { 0, 1, 2, 3 };
	dice[1][3][1] = { 1, 0, 3, 6 };
	dice[1][4][0] = { 0, -1, 2, 4 };
	dice[1][4][1] = { -1, 0, 3, 1 };
	dice[1][5][0] = { -1, 0, 2, 1 };
	dice[1][5][1] = { 0, 1, 3, 5 };

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

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

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

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

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


	int n;

	while (1){
		cin >> n;
		if (n == 0){
		//	cin.close();
		//	cout.close();
			return 0;
		}

		fill(&table[0][0][0], &table[0][0][0] + 100 * 300 * 300, 0);
		fill(&table_b[0][0], &table_b[0][0] + 300 * 300, false);
		fill(dice_num, dice_num + 6, 0);

		while (n--){
			int aa, bb;
			cin >> aa >> bb;
			int hh = 0;
			while (table[hh][150][150]){
				++hh;
			}
			func(aa, bb, 150, 150, hh);
			n;
		}

		for (int i = 99; i >= 0; i--){
			REP(j, 300){
				REP(k, 300){
					if (table[i][j][k] && !table_b[j][k]){
						table_b[j][k] = true;
						dice_num[table[i][j][k] - 1]++;
					}
				}
			}

		}

		REP(i, 6){
			cout << dice_num[i];
			if(i!=5)cout << " ";
		}
		cout << endl;

	}
}

Measured memory_bytes: 36412