#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

class Sai {
public:
	int up, down, north, south, east, west;

	Sai(){}
	Sai(int _up, int _south)
	{
		up = _up;
		south = _south;
		down = 7 - up;
		north = 7 - south;

		switch (up) {
		case 1:
			switch (south) {
			case 2:
				east = 3;
				west = 4;
				break;
			case 3:
				east = 5;
				west = 2;
				break;
			case 4:
				east = 2;
				west = 5;
				break;
			case 5:
				east = 4;
				west = 3;
				break;
			}
			break;
		case 2:
			switch (south) {
			case 1:
				east = 4;
				west = 3;
				break;
			case 3:
				east = 1;
				west = 6;
				break;
			case 4:
				east = 6;
				west = 1;
				break;
			case 6:
				east = 3;
				west = 4;
				break;
			}
			break;
		case 3:
			switch (south) {
			case 1:
				east = 2;
				west = 5;
				break;
			case 2:
				east = 6;
				west = 1;
				break;
			case 5:
				east = 1;
				west = 6;
				break;
			case 6:
				east = 5;
				west = 2;
				break;
			}
			break;
		case 4:
			switch (south) {
			case 1:
				east = 5;
				west = 2;
				break;
			case 2:
				east = 1;
				west = 6;
				break;
			case 5:
				east = 6;
				west = 1;
				break;
			case 6:
				east = 2;
				west = 5;
				break;
			}
			break;
		case 5:
			switch (south) {
			case 1:
				east = 3;
				west = 4;
				break;
			case 3:
				east = 6;
				west = 1;
				break;
			case 4:
				east = 1;
				west = 6;
				break;
			case 6:
				east = 4;
				west = 3;
				break;
			}
			break;
		case 6:
			switch (south) {
			case 2:
				east = 4;
				west = 3;
				break;
			case 3:
				east = 2;
				west = 5;
				break;
			case 4:
				east = 5;
				west = 2;
				break;
			case 5:
				east = 3;
				west = 4;
				break;
			}
			break;
		}
	}

	void fall_north()
	{
		int temp = up;
		up = south;
		south = down;
		down = north;
		north = temp;
	}

	void fall_south()
	{
		int temp = up;
		up = north;
		north = down;
		down = south;
		south = temp;
	}

	void fall_east()
	{
		int temp = up;
		up = west;
		west = down;
		down = east;
		east = temp;
	}

	void fall_west()
	{
		int temp = up;
		up = east;
		east = down;
		down = west;
		west = temp;
	}
};

bool isrange(int x, int y)
{
	return (x >= 0 && x < 110 && y >= 0 && y < 110);
}

//east,south,west,north
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	while (true) {
		int n;

		cin >> n;

		if (n == 0) {
			break;
		}

		int map[210][210];
		int height[210][210];

		rep(i, 210) {
			rep(j, 210) {
				height[i][j] = 0;
			}
		}

		rep(i, n) {
			int up, south;

			cin >> up >> south;

			Sai sai(up, south);
			int x = 105;
			int y = 105;
			int nx, ny;
			bool flag = true;

			while (true) {
				flag = false;

				rep(i, 4) {
					nx = x + dx[i];
					ny = y + dy[i];

					switch (i) {
					case 0:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.east == 6) {
								sai.fall_east();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 1:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.south == 6) {
								sai.fall_south();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 2:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.west == 6) {
						 		sai.fall_west();
						   		x =	nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 3:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.north == 6) {
								sai.fall_north();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					}
				}

				if (flag == true) {
					continue;
				}

				rep(i, 4) {
					nx = x + dx[i];
					ny = y + dy[i];

					switch (i) {
					case 0:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.east == 5) {
								sai.fall_east();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 1:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.south == 5) {
								sai.fall_south();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 2:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.west == 5) {
								sai.fall_west();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 3:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.north == 5) {
								sai.fall_north();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					}
				}

				if (flag == true) {
					continue;
				}

				rep(i, 4) {
					nx = x + dx[i];
					ny = y + dy[i];

					switch (i) {
					case 0:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.east == 4) {
								sai.fall_east();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 1:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.south == 4) {
								sai.fall_south();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 2:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.west == 4) {
								sai.fall_west();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					case 3:
						if (isrange(nx, ny) == true && height[y][x] - height[ny][nx] > 0) {
							if (sai.north == 4) {
								sai.fall_north();
								x = nx;
								y = ny;
								flag = true;
								break;
							}
						}
						break;
					}
				}

				if (flag == false) {
					map[y][x] = sai.up;
					height[y][x]++;
					break;
				}
			}
		}

		int count[6] = { 0,0,0,0,0,0 };

		rep(i, 210) {
			rep(j, 210) {
				if (height[i][j] != 0) {
					count[map[i][j] - 1]++;
				}
			}
		}

		cout << count[0] << " " << count[1] << " " << count[2] << " " << count[3] << " " << count[4] << " " << count[5] << endl;
	}

	return 0;
}

Measured memory_bytes: 3272