#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int lint;
struct {
	int nDice, tmp_score, last_score;
} mp[201][201] = { };

int opposide[7] = { 0, 6, 5, 4, 3, 2, 1 };
int right_side[7][7] = {{ },
						{0, 0, 3, 5, 2, 4},
						{0, 4, 0, 1, 6, 0, 3},
						{0, 2, 6, 0, 0, 1, 5},
						{0, 5, 1, 0, 0, 6, 2},
						{0, 3, 0, 6, 1, 0, 4},
						{0, 0, 4, 2, 5, 3}};
int final_score[7] = { };

void roll(int top, int front, int row, int col);

int main()
{
	int n = 0;
	while(scanf("%d", &n) == 1 && n != 0)
	{
		int top = 0, front = 0;
		for(int i = 0; i < 201; i++)
			for(int j = 0; j < 201; j++)
				mp[i][j].nDice = mp[i][j].tmp_score = mp[i][j].last_score = 0;
		for(int i = 1; i < 7; i++)
			final_score[i] = 0;
		while(n-- > 0)
		{
			scanf("%d %d", &top, &front);
			mp[100][100].nDice++;
			final_score[mp[100][100].tmp_score]--;
			mp[100][100].last_score = mp[100][100].tmp_score;
			mp[100][100].tmp_score = top;
			final_score[top]++;
			roll(top, front, 100, 100);
		}
		for(int i = 1; i < 7; i++)
			printf("%d%s", final_score[i], i == 6? "\n" : " ");
	}
	return 0;
}

void roll(int top, int front, int row, int col)
{
	int dire = 0;
	for(int i = 4; i < 7; i++)
	{
		if(i != top && i != opposide[top])
		{
			if(i == front && mp[row + 1][col].nDice + 1 < mp[row][col].nDice)
					dire = dire > i ? dire : i;
			else if(i == opposide[front] && mp[row - 1][col].nDice + 1 < mp[row][col].nDice)
					dire = dire > i ? dire : i;
			else if(i == right_side[top][front] && mp[row][col + 1].nDice + 1 < mp[row][col].nDice)
					dire = dire > i ? dire : i;
			else if(i == opposide[right_side[top][front]] && mp[row][col - 1].nDice + 1 < mp[row][col].nDice)
					dire = dire > i ? dire : i;
		}
	}
	if(dire > 0)
	{
		mp[row][col].nDice--;
		final_score[mp[row][col].tmp_score]--;
		mp[row][col].tmp_score = mp[row][col].last_score;
		final_score[mp[row][col].tmp_score]++;
		if(dire == front)
		{
			mp[row + 1][col].nDice++;
			final_score[mp[row + 1][col].tmp_score]--;
			final_score[opposide[front]]++;
			mp[row + 1][col].last_score = mp[row + 1][col].tmp_score;
			mp[row + 1][col].tmp_score = opposide[front];
			roll(opposide[front], top, row + 1, col);
		}
		else if(dire == opposide[front])
		{
			mp[row - 1][col].nDice++;
			final_score[mp[row - 1][col].tmp_score]--;
			mp[row - 1][col].last_score = mp[row - 1][col].tmp_score;
			mp[row - 1][col].tmp_score = front;
			final_score[mp[row - 1][col].tmp_score]++;
			roll(front, opposide[top], row - 1, col);
		}
		else if(dire == right_side[top][front])
		{
			mp[row][col + 1].nDice++;
			final_score[mp[row][col + 1].tmp_score]--;
			mp[row][col + 1].last_score = mp[row][col + 1].tmp_score;
			mp[row][col + 1].tmp_score = opposide[right_side[top][front]];
			final_score[mp[row][col + 1].tmp_score]++;
			roll(opposide[right_side[top][front]], front, row, col + 1);
		}
		else if(dire == opposide[right_side[top][front]])
		{
			mp[row][col - 1].nDice++;
			final_score[mp[row][col - 1].tmp_score]--;
			mp[row][col - 1].last_score = mp[row][col - 1].tmp_score;
			mp[row][col - 1].tmp_score = right_side[top][front];
			final_score[mp[row][col - 1].tmp_score]++;
			roll(right_side[top][front], front, row, col - 1);
		}
	}
}

Measured memory_bytes: 0