#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

const int C = 50;
int ex[100][100][100];
int num[7];
int n;

vector<int> check(int t, int f){
	vector<int> v(7);
	
	if(t == 1 && f == 2){ v[0] =  0; v[1] = -1; v[2] = 5; v[3] = -1; v[4] =  0; v[5] = 4;}
	if(t == 1 && f == 3){ v[0] =  1; v[1] =  0; v[2] = 5; v[3] =  0; v[4] = -1; v[5] = 4;}
	if(t == 1 && f == 4){ v[0] = -1; v[1] =  0; v[2] = 5; v[3] =  0; v[4] =  1; v[5] = 4;}
	if(t == 1 && f == 5){ v[0] =  0; v[1] =  1; v[2] = 5; v[3] =  1; v[4] =  0; v[5] = 4;}
		
	if(t == 2 && f == 1){ v[0] =  0; v[1] = -1; v[2] = 6; v[3] =  1; v[4] =  0; v[5] = 4;}
	if(t == 2 && f == 3){ v[0] = -1; v[1] =  0; v[2] = 6; v[3] =  0; v[4] = -1; v[5] = 4;}
	if(t == 2 && f == 4){ v[0] =  1; v[1] =  0; v[2] = 6; v[3] =  0; v[4] =  1; v[5] = 4;}
	if(t == 2 && f == 6){ v[0] =  0; v[1] =  1; v[2] = 6; v[3] = -1; v[4] =  0; v[5] = 4;}
		
	if(t == 3 && f == 1){ v[0] =  0; v[1] = -1; v[2] = 6; v[3] = -1; v[4] =  0; v[5] = 5;}
	if(t == 3 && f == 2){ v[0] =  1; v[1] =  0; v[2] = 6; v[3] =  0; v[4] = -1; v[5] = 5;}
	if(t == 3 && f == 5){ v[0] = -1; v[1] =  0; v[2] = 6; v[3] =  0; v[4] =  1; v[5] = 5;}
	if(t == 3 && f == 6){ v[0] =  0; v[1] =  1; v[2] = 6; v[3] =  1; v[4] =  0; v[5] = 5;}
		
	if(t == 4 && f == 1){ v[0] =  0; v[1] = -1; v[2] = 6; v[3] =  1; v[4] =  0; v[5] = 5;}
	if(t == 4 && f == 2){ v[0] = -1; v[1] =  0; v[2] = 6; v[3] =  0; v[4] = -1; v[5] = 5;}
	if(t == 4 && f == 5){ v[0] =  1; v[1] =  0; v[2] = 6; v[3] =  0; v[4] =  1; v[5] = 5;}
	if(t == 4 && f == 6){ v[0] =  0; v[1] =  1; v[2] = 6; v[3] = -1; v[4] =  0; v[5] = 5;}
	
	if(t == 5 && f == 1){ v[0] =  0; v[1] = -1; v[2] = 6; v[3] = -1; v[4] =  0; v[5] = 4;}
	if(t == 5 && f == 3){ v[0] =  1; v[1] =  0; v[2] = 6; v[3] =  0; v[4] = -1; v[5] = 4;}
	if(t == 5 && f == 4){ v[0] = -1; v[1] =  0; v[2] = 6; v[3] =  0; v[4] =  1; v[5] = 4;}
	if(t == 5 && f == 6){ v[0] =  0; v[1] =  1; v[2] = 6; v[3] =  1; v[4] =  0; v[5] = 4;}
	
	if(t == 6 && f == 2){ v[0] =  0; v[1] = -1; v[2] = 5; v[3] =  1; v[4] =  0; v[5] = 4;}
	if(t == 6 && f == 3){ v[0] = -1; v[1] =  0; v[2] = 5; v[3] =  0; v[4] = -1; v[5] = 4;}
	if(t == 6 && f == 4){ v[0] =  1; v[1] =  0; v[2] = 5; v[3] =  0; v[4] =  1; v[5] = 4;}
	if(t == 6 && f == 5){ v[0] =  0; v[1] =  1; v[2] = 5; v[3] = -1; v[4] =  0; v[5] = 4;}
	return v;
}

int main(){
	while(scanf("%d",&n),n){
		memset(ex,-1,sizeof(ex));
		memset(num,0,sizeof(num));
		rep(i,n){	
			int t, f;
			scanf("%d%d",&t,&f);
			int dx = 0, dy = 0;
			vector<int> v = check(t,f);
			
			for(int j = 0; j < 99; j++){
				if(ex[j+1][C+dx][C+dy] != -1){
					if(ex[j+1][C+dx+v[0]][C+dy+v[1]] == -1){
						dx += v[0];
						dy += v[1];
						if(v[1] ==  1) f = t;
						if(v[1] == -1) f = 7-t;
						t = 7-v[2];
						v = check(t,f);
					} else if(ex[j+1][C+dx+v[3]][C+dy+v[4]] == -1){
						dx += v[3];
						dy += v[4];
						if(v[4] ==  1) f = t;
						if(v[4] == -1) f = 7-t;
						t = 7-v[5];
						v = check(t,f);
					} else{
						ex[j][C+dx][C+dy] = t;
						//cout << j << " " << C+dx << " " << C+dy << " " << t << endl;
						break;
					}
				}
				if(j == 98){
					ex[j+1][C+dx][C+dy] = t;
					//cout << j << " " << C+dx << " " << C+dy << " " << t << endl;
					break;
				}
			}
		}
		for(int j = 0; j < 100; j++){
			for(int k = 0; k < 100; k++){
				for(int u = 0; u < 100; u++){
					if(ex[u][j][k] != -1){
						num[ex[u][j][k]]++;
						break;
					}
				}
			}
		}
		printf("%d %d %d %d %d %d\n",num[1],num[2],num[3],num[4],num[5],num[6]);
	}
}

Measured memory_bytes: 5116