#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum DIR{
	N,
	W,
	E,
	S,
};

int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
int NumDice,start_row = 102,start_col = 102;

char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";

class Dice{
public:
	Dice(){
		height = 0;
	};

	void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'S':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'N':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	void firstPos(int top,int south){

		for(int i = 0; i < 24; i++){
			roll(order[i]);
			if(getTop() == top && getSouth() == south)break;
		}
	}

	int getTop(){
		return number[0];
	}

	int getSouth(){
		return number[4];
	}

	int ifTurnN(){
		return number[1];
	}

	int ifTurnW(){
		return number[3];
	}

	int ifTurnE(){
		return number[2];
	}

	int ifTurnS(){
		return number[4];
	}

	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

	void init(){
		setNumber(1,4,5,2,3,6);
	}

	void set(Dice arg){
		for(int i = 0; i < 6; i++){
			number[i] = arg.number[i];
		}
	}

	int number[6];
	int work[6];
	int height;
};

Dice** map;

void func(){

	for(int row = start_row-(NumDice-1); row <= start_row+(NumDice-1); row++){
		for(int col = start_col-(NumDice-1);col <= start_col+(NumDice-1);col++){
			map[row][col].height = 0;
		}
	}

	int top,south,row,col,maximum,next_row,next_col,tmp;
	DIR max_dir;


	for(int loop = 0; loop < NumDice; loop++){
		scanf("%d %d",&top,&south);

		Dice dice;
		dice.init();
		dice.firstPos(top,south);

		row = start_row;
		col = start_col;

		while(true){

			maximum = 0;
			for(int i = 0; i < 4; i++){
				next_row = row + diff_row[i];
				next_col = col + diff_col[i];

				if(map[next_row][next_col].height < map[row][col].height){
					switch(i){
					case 0: //N
						if((tmp = dice.ifTurnN()) >= 4){
							if(maximum < tmp){
								maximum = tmp;
								max_dir = N;
							}
						}
						break;
					case 1: //W
						if((tmp = dice.ifTurnW()) >= 4){
							if(maximum < tmp){
								maximum = tmp;
								max_dir = W;
							}
						}
						break;
					case 2: //E
						if((tmp = dice.ifTurnE()) >= 4){
							if(maximum < tmp){
								maximum = tmp;
								max_dir = E;
							}
						}
						break;
					case 3: //S
						if((tmp = dice.ifTurnS()) >= 4){
							if(maximum < tmp){
								maximum = tmp;
								max_dir = S;
							}
						}
						break;
					}
				}
			}


			if(maximum == 0){
				for(int k = 0; k < 6; k++)map[row][col].number[k] = dice.number[k];
				map[row][col].height++;
				break;
			}else{

				switch(max_dir){
				case N:
					dice.roll('N');
					row--;
					break;
				case W:
					dice.roll('W');
					col--;
					break;
				case E:
					dice.roll('E');
					col++;
					break;
				case S:
					dice.roll('S');
					row++;
					break;
				}
			}
		}

	}

	int ans[7] = {0,0,0,0,0,0,0};

	for(int row = start_row-(NumDice-1); row <= start_row+(NumDice-1); row++){
		for(int col = start_col-(NumDice-1);col <= start_col+(NumDice-1);col++){
			if(map[row][col].height > 0){
				ans[map[row][col].getTop()]++;
			}
		}
	}

	printf("%d",ans[1]);
	for(int i = 2; i <= 6; i++){
		printf(" %d",ans[i]);
	}
	printf("\n");

}

int main(){

	map = (Dice**)malloc(sizeof(Dice*)*205);
	for(int i = 0; i < 205; i++){
		map[i] = (Dice*)malloc(sizeof(Dice)*205);
	}

	while(true){
		scanf("%d",&NumDice);
		if(NumDice == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 4808