#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
int ds[205][205];
int hs[205][205];

int getr(int t,int f){
	int c=0;
	if(t>=4){
		c=1-c; t=7-t;
	}
	if(f>=4){
		c=1-c; f=7-f;
	}
	int res=t+f+1;
	if((t+1)%3==f%3)res=7-res;
	if(c==1)res=7-res;
	return res;
}

int main(void){
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		memset(hs,0,sizeof(hs));
		memset(ds,0,sizeof(ds));
		
		rep(qqq,n){
			int t,f;
			scanf("%d%d",&t,&f);
			int y=100,x=100;
			for(;;){
				bool rd=false;
				ireg(i,4,6){
					if(i==t || i==7-t)continue;
					int r=getr(t,f),dy,dx,tt,tf;
					if(i==f){
						dx=0; dy=1; tt=7-f; tf=t;
					}
					else if(i==7-f){
						dx=0; dy=-1; tt=f; tf=7-t;
					}
					else if(i==r){
						dy=0; dx=1; tt=7-r; tf=f;
					}
					else{
						dy=0; dx=-1; tt=r; tf=f;
					}
					
					int ty=y+dy,tx=x+dx;
					if(hs[ty][tx]<hs[y][x]){
						y = ty; x = tx;
						t = tt; f = tf;
						rd=true;
						break;
					}
				}
				if(!rd){
					hs[y][x]++;
					ds[y][x]=t;
					break;
				}
			}
		}
		int anss[7];
		rep(i,7)anss[i]=0;
		rep(i,205)rep(j,205){
			anss[ds[i][j]]++;
		}
		reg(i,1,6)printf("%d%c",anss[i],i==6?'\n':' ');
	}
	return 0;
}