//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 100000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

 
//int dy[5] = { 0,0,1,-1,0 };
//int dx[5] = { 1,-1,0,0,0 };

int dy[5] = { -1,0,1,0,0 };
int dx[5] = { 0,-1,0,1,0 };

struct edge{long long int to,cost;};

 
int main(void){

	while(1){
		int n;
		int now[210][210]={};//真ん中、belowから時計回り
		int res[5]={};
		int high[210][210]={};

		cin>>n;

		if(n==0){
			break;
		}

		int t,f;
		int maxi;
		int pos;
		int x,y;
		int delx,dely;

		FOR(i,1,n){
			cin>>t>>f;
			x=101;
			y=101;

			while(1){
				
				res[0]=t;
				res[1]=f;
			
			
			switch(t){
				case 1:
				switch(f){
					case 2:
						res[2]=4;
						res[3]=5;
						res[4]=3;
					break;
					case 3:
						res[2]=2;
						res[3]=4;
						res[4]=5;
					break;
					case 4:
						res[2]=5;
						res[3]=3;
						res[4]=2;
					break;
					case 5:
						res[2]=3;
						res[3]=2;
						res[4]=4;
					break;
				}
				break;
				case 2:
				switch(f){
					case 1:
						res[2]=3;
						res[3]=6;
						res[4]=4;
					break;
					case 3:
						res[2]=6;
						res[3]=4;
						res[4]=1;
					break;
					case 4:
						res[2]=1;
						res[3]=3;
						res[4]=6;
					break;
					case 6:
						res[2]=4;
						res[3]=1;
						res[4]=3;
					break;
				}
				break;
				case 3:
				switch(f){
					case 1:
						res[2]=5;
						res[3]=6;
						res[4]=2;
					break;
					case 2:
						res[2]=1;
						res[3]=5;
						res[4]=6;
					break;
					case 5:
						res[2]=6;
						res[3]=2;
						res[4]=1;
					break;
					case 6:
						res[2]=2;
						res[3]=1;
						res[4]=5;
					break;
				}
				break;
				case 4:
				switch(f){
					case 1:
						res[2]=2;
						res[3]=6;
						res[4]=5;
					break;
					case 2:
						res[2]=6;
						res[3]=5;
						res[4]=1;
					break;
					case 5:
						res[2]=1;
						res[3]=2;
						res[4]=6;
					break;
					case 6:
						res[2]=5;
						res[3]=1;
						res[4]=2;
					break;
				}
				break;
				case 5:
				switch(f){
					case 1:
						res[2]=4;
						res[3]=6;
						res[4]=3;
					break;
					case 3:
						res[2]=1;
						res[3]=4;
						res[4]=6;
					break;
					case 4:
						res[2]=6;
						res[3]=3;
						res[4]=1;
					break;
					case 6:
						res[2]=3;
						res[3]=1;
						res[4]=4;
					break;
				}
				break;
				case 6:
				switch(f){
					case 2:
						res[2]=3;
						res[3]=5;
						res[4]=4;
					break;
					case 3:
						res[2]=5;
						res[3]=4;
						res[4]=2;
					break;
					case 4:
						res[2]=2;
						res[3]=3;
						res[4]=5;
					break;
					case 5:
						res[2]=4;
						res[3]=2;
						res[4]=3;
					break;
				}
				break;
			}

			maxi=0;
			delx=-1;
			dely=-1;
			pos=0;
			FOR(j,0,3){
				if(high[y][x]>high[y+dy[j]][x+dx[j]]&&res[j+1]>=4){
					if(maxi<res[j+1]){
						pos=j+1;
						delx=x+dx[j];
						dely=y+dy[j];
						maxi=res[j+1];
					}
				}
			}

			
				if(pos!=0){
					switch(pos){
						case  1:
							t=res[3];
							f=res[0];
						break;
						case  2:
							t=res[4];
							f=res[1];
						break;
						case 3:
							t=res[1];
							f=7-res[0];
						break;
						case 4:
							t=res[2];
							f=res[1];
						break;
					}
					y=dely;
					x=delx;
				}else{
					now[y][x]=res[0];
					high[y][x]++;
					break;
				}
				
			
			}


		}


		int count=0;
		FOR(i,1,6){
			count=0;
			FOR(j,0,209){
				FOR(k,0,209){
					if(now[j][k]==i){
						count++;
					}
				}
			}
			if(i!=6){
				cout<<count<<" ";
			}else{
				cout<<count<<endl;
			}
		}

	

	}

}




Measured memory_bytes: 3436