#include<iostream>
#include<cstring>

#define UP 0
#define RIGHT 1
#define DOWN 2
#define LEFT 3

using namespace std;
int role(int top, int below, int dir) {
	int ret = 0;
	if(dir == UP) {
		if(top == 1) {
			if(below == 2) { ret = 5; }
			else if(below == 3) { ret = 4; }
		} else if(top == 2) {
			if(below == 1) { ret = 6; }
			else if(below == 3) { ret = 4; }
		} else if(top == 3) {
			if(below == 1) { ret = 6; }
			else if(below == 2) { ret = 5; }
		} else if(top == 4) {
			if(below == 1) { ret = 6; }
			else if(below == 2) { ret = 5; }
		} else if(top == 5) {
			if(below == 1) { ret = 6; }
			else if(below == 3) { ret = 4; }
		} else if(top == 6) {
			if(below == 2) { ret = 5; }
			else if(below == 3) { ret = 4; }
		}
	} else if(dir == RIGHT) {
		if(top == 1) {
			if(below == 3) { ret = 5; }
			else if(below == 5) { ret = 4; }
		} else if(top == 2) {
			if(below == 1) { ret = 4; }
			else if(below == 4) { ret = 6; }
		} else if(top == 3) {
			if(below == 2) { ret = 6; }
			else if(below == 6) { ret = 5; }
		} else if(top == 4) {
			if(below == 1) { ret = 5; }
			else if(below == 5) { ret = 6; }
		} else if(top == 5) {
			if(below == 3) { ret = 6; }
			else if(below == 6) { ret = 4; }
		} else if(top == 6) {
			if(below == 2) { ret = 4; }
			else if(below == 4) { ret = 5; }
		}
	} else if(dir == DOWN) {
		if(top == 1) {
			if(below == 4) { ret = 4; }
			else if(below == 5) { ret = 5; }
		} else if(top == 2) {
			if(below == 4) { ret = 4; }
			else if(below == 6) { ret = 6; }
		} else if(top == 3) {
			if(below == 5) { ret = 5; }
			else if(below == 6) { ret = 6; }
		} else if(top == 4) {
			if(below == 5) { ret = 5; }
			else if(below == 6) { ret = 6; }
		} else if(top == 5) {
			if(below == 4) { ret = 4; }
			else if(below == 6) { ret = 6; }
		} else if(top == 6) {
			if(below == 4) { ret = 4; }
			else if(below == 5) { ret = 5; }
		}
	} else if(dir == LEFT) {
		if(top == 1) {
			if(below == 2) { ret = 4; }
			else if(below == 4) { ret = 5; }
		} else if(top == 2) {
			if(below == 3) { ret = 6; }
			else if(below == 6) { ret = 4; }
		} else if(top == 3) {
			if(below == 1) { ret = 5; }
			else if(below == 5) { ret = 6; }
		} else if(top == 4) {
			if(below == 2) { ret = 6; }
			else if(below == 6) { ret = 5; }
		} else if(top == 5) {
			if(below == 1) { ret = 4; }
			else if(below == 4) { ret = 6; }
		} else if(top == 6) {
			if(below == 3) { ret = 5; }
			else if(below == 5) { ret = 4; }
		}
	}
	return ret;
}

int getback(int i) {
	int ret = 0;
	if(i == 1) { ret = 6; }
	else if(i == 2) { ret = 5; }
	else if(i == 3) { ret = 4; }
	else if(i == 4) { ret = 3; }
	else if(i == 5) { ret = 2; }
	else if(i == 6) { ret = 1; }
	return ret;
}

int main(void) {
	int num[150][150], height[150][150];
	int res[6];
	int n, top, below, x, y, up, right, down, left, dirmax;
	int i, j;

	while(true) {
		cin >> n;
		if(n == 0 || cin.eof()) { break; }
		memset(num, 0, sizeof(num));
		memset(height, 0, sizeof(height));
		memset(res, 0, sizeof(res));
		for(i = 0; i < n; i++) {
			cin >> top >> below;
			x = y = 75;
			while(true) {
				up = role(top, below, UP) * ((height[x][y] > height[x][y-1])?1:0);
				right = role(top, below, RIGHT) * ((height[x][y] > height[x+1][y])?1:0);
				down = role(top, below, DOWN) * ((height[x][y] > height[x][y+1])?1:0);
				left = role(top, below, LEFT) * ((height[x][y] > height[x-1][y])?1:0);
				dirmax = max(max(max(up,right),down),left);
				if(dirmax == 0) { break; }
				if(up == dirmax) {
					y--;
					below = getback(top);
					top = getback(dirmax);
				} else if(right == dirmax) {
					x++;
					top= getback(dirmax);
				} else if(down == dirmax) {
					y++;
					below = top;
					top = getback(dirmax);
				} else if(left == dirmax) {
					x--;
					top = getback(dirmax);
				}
			}
			height[x][y]++;
			num[x][y] = top;
		}
		for(i = 0; i < 150; i++) {
			for(j = 0; j < 150; j++) {
				res[num[i][j]-1]++;
			}
		}
		for(i = 0; i < 6; i++) {
			cout << res[i] << ((i < 5)?" ":"");
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0