#include <iostream>
#define N1 35
using namespace std;
void Dice(int,int,int,int);
pair<int,int> data[N1][N1];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int dice[6][4]={{2,3,5,4},{1,4,6,3},{1,2,6,5},{1,5,6,2},{1,3,6,4},{2,4,5,3}};
int main(){
  int n,t,f,d,i,j,cnt[6];
  d=N1/2;
  while(1){
    for(i=0;i<N1;i++){
      for(j=0;j<N1;j++){
	data[i][j].first=data[i][j].second=0;
      }
    }
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> t >> f;
      Dice(t,f,d,d);
    }
    for(i=0;i<6;i++) cnt[i]=0;
    for(i=0;i<N1;i++){
      for(j=0;j<N1;j++){
	if(data[i][j].first!=0) cnt[data[i][j].first-1]++;
      }
    }
    for(i=0;i<6;i++){
      if(i!=5) cout << cnt[i] << ' ';
      else cout << cnt[i];
    }
    cout << endl;
  }
}
void Dice(int t,int f,int y,int x){
  int s,max=3,a,r;
  for(int i=0;i<4;i++){
    if(dice[t-1][i]==f) s=i;
  }
  for(int i=0;i<4;i++){
    if(max<dice[t-1][(s+i)%4]&&data[y][x].second>data[y+dy[i]][x+dx[i]].second){
      max=dice[t-1][(s+i)%4];
      r=i;
    }
  }
  if(max!=3){
    if(r==1||r==3) a=f;
    else if(r==2) a=7-t;
    else a=t;
    Dice(7-max,a,y+dy[r],x+dx[r]);
  }else{
    data[y][x].first=t;
    data[y][x].second++;
  }
}/*
   void Dice(int t,int f,int y,int x){
   int s,cp,max=0,max2=0,cnt=2,flag,j;
   while(cnt){
   for(int i=0;i<4;i++){
   if(dice[t-1][i]==f) cp=s=i;
   }
   for(int i=0;i<4;i++){
   cout << "cnt=" << cnt << "max=" << max << " max2=" << max2 << endl;
   if(cnt==2&&max<dice[t-1][s]){
   max=dice[t-1][s];
   j=i;
   }
   else if(cnt==1&&max2<dice[t-1][s]&&max2<max){
   cout << "ioewdsifidjfiodsi" << endl;
   max2=dice[t-1][s];
   j=i;
   }
   s++;
   if(s==4) s=0;
   }
   cout << "j= " << j << endl;
   flag=0;
   if(j==0&&data[y][x].second>data[y+dy[j]][x+dx[j]].second){
   Dice(7-f,t,y+dy[j],x+dx[j]),flag=1;
   }
   else if(j==1&&data[y][x].second>data[y+dy[j]][x+dx[j]].second){
   cout << data[y][x].second << ' ' <<  data[y+dy[j]][x+dx[j]].second << endl;
   Dice(7-dice[t-1][(cp+j)%4],f,y+dy[j],x+dx[j]),flag=1;
   }
   else if(j==2&&data[y][x].second>data[y+dy[j]][x+dx[j]].second){
   Dice(f,7-t,y+dy[j],x+dx[j]),flag=1;
   }
   else if(j==3&&data[y][x].second>data[y+dy[j]][x+dx[j]].second){
   Dice(7-dice[t-1][cp+j],f,y+dy[j],x+dx[j]),flag=1;
   }
   if(flag==0&&flag2==0){
   //      cout << y << ' ' << x << endl;
   data[y][x].second++;
   data[y][x].first=t;
   flag2=1;
   }
   cout << flag2 << endl;
   if(flag2==1) cnt--;
   cnt--;
   }
   }
 */