#include <stdio.h>
#include <memory.h>

//FILE *in = freopen("input.txt", "r", stdin);

int n;
int data[200][200];
int up[200][200];

int mvx[4]={1,0,-1,0};
int mvy[4]={0,1,0,-1};

int* makeArr(int a, int b, int c, int d, int e, int f) {
	int* arr = new int[6];
	arr[0] = a;
	arr[1] = b;
	arr[2] = c;
	arr[3] = d;
	arr[4] = e;
	arr[5] = f;
	return arr;
}

int* getDice(int* dice, int to) {
	// 0, 1,  2,   3,   4,  5
	// t, f, f+1, f+2, f+3, b
	switch(to) {
	case 1:
		return makeArr(dice[3], dice[0], dice[2], dice[5], dice[4], dice[1]);
	case 2:
		return makeArr(dice[4], dice[1], dice[0], dice[3], dice[5], dice[2]);
	case 3:
		return makeArr(dice[1], dice[5], dice[2], dice[0], dice[4], dice[3]);
	case 4:
		return makeArr(dice[2], dice[1], dice[5], dice[3], dice[0], dice[4]);
	}
	return nullptr;
}

int* initDice(int t, int f) {
	switch(t){
	case 1:
		switch(f){
		case 1:
			return makeArr(0,0,0,0,0,0);
		case 2:
			return makeArr(1,2,3,5,4,6);
		case 3:
			return makeArr(1,3,5,4,2,6);
		case 4:
			return makeArr(1,4,2,3,5,6);
		case 5:
			return makeArr(1,5,4,2,3,6);
		case 6:
			return makeArr(0,0,0,0,0,0);
		}
	case 2:
		switch(f){
		case 1:
			return makeArr(2,1,4,6,3,5);
		case 2:
			return makeArr(0,0,0,0,0,0);
		case 3:
			return makeArr(2,3,1,4,6,5);
		case 4:
			return makeArr(2,4,6,3,1,5);
		case 5:
			return makeArr(0,0,0,0,0,0);
		case 6:
			return makeArr(2,6,3,1,4,5);
		}
	case 3:
		switch(f){
		case 1:
			return makeArr(3,1,2,6,5,4);
		case 2:
			return makeArr(3,2,6,5,1,4);
		case 3:
			return makeArr(0,0,0,0,0,0);
		case 4:
			return makeArr(0,0,0,0,0,0);
		case 5:
			return makeArr(3,5,1,2,6,4);
		case 6:
			return makeArr(3,6,5,1,2,4);
		}
	case 4:
		switch(f){
		case 1:
			return makeArr(4,1,5,6,2,3);
		case 2:
			return makeArr(4,2,1,5,6,3);
		case 3:
			return makeArr(0,0,0,0,0,0);
		case 4:
			return makeArr(0,0,0,0,0,0);
		case 5:
			return makeArr(4,5,6,2,1,3);
		case 6:
			return makeArr(4,6,2,1,5,3);
		}
	case 5:
		switch(f){
		case 1:
			return makeArr(5,1,3,6,4,2);
		case 2:
			return makeArr(0,0,0,0,0,0);
		case 3:
			return makeArr(5,3,6,4,1,2);
		case 4:
			return makeArr(5,4,1,3,6,2);
		case 5:
			return makeArr(0,0,0,0,0,0);
		case 6:
			return makeArr(5,6,4,1,3,2);
		}
	case 6:
		switch(f){
		case 1:
			return makeArr(0,0,0,0,0,0);
		case 2:
			return makeArr(6,2,4,5,3,1);
		case 3:
			return makeArr(6,3,2,4,5,1);
		case 4:
			return makeArr(6,4,5,3,2,1);
		case 5:
			return makeArr(6,5,3,2,4,1);
		case 6:
			return makeArr(0,0,0,0,0,0);
		}
	}
}

//dice
// t, f, f+1, f+2, f+3, f+4, d

void roll(int x, int y, int* dice) {
	int Max=0, pos;
	for(int i = 1; i <=4; i++) {
		if(dice[i]>=4 && Max < dice[i] && (data[x+mvx[i-1]][y+mvy[i-1]] < data[x][y])) {
			Max = dice[i];
			pos = i;
		}
	}
	if(Max >= 4) {
		roll(x+mvx[pos-1],y+mvy[pos-1],getDice(dice,pos));
		return;
	}
	data[x][y]++;
	up[x][y] = dice[0];
}

//FILE *out = fopen("output.txt", "w");
//void debug(){
//	for(int i = 0; i < 200; i++){
//		for(int j = 0; j < 200; j++){
//			fprintf(out, "%d", up[i][j]);
//		}
//		fprintf(out, "\n");
//	}
//	fprintf(out, "\n");
//}

void process(){
	int x, y;
	for(int i = 0; i < n; i++) {
		scanf("%d%d", &x, &y);
		int *dice = initDice(x,y);
		roll(100, 100, dice);
		//debug();
	}
}

void output() {
	int cnt[7] = {0,0,0,0,0,0,0};
	for(int i = 0; i < 200; i++){
		for(int j = 0; j < 200; j++){
			cnt[up[i][j]]++;
		}
	}
	for(int i = 1; i < 6; i++) {
		printf("%d ", cnt[i]);
	}
	printf("%d\n", cnt[6]);
}

void init() {
	memset(data, 0, sizeof(data));
	memset(up, 0, sizeof(up));
}

int main() {
	while(true) {
		init();
		scanf("%d", &n);
		if (n==0) break;
		process();
		output();
	}
	return 0;
}

Measured memory_bytes: 1576