#include<cstdio>
#include<cstring>

#define NUMM(x,y) (num[Mx(x)][My(y)])
#define NUMF(x,y) (num[Fx(x)][Fy(y)])
#define NUMB(x,y) (num[Bx(x)][By(y)])
#define NUML(x,y) (num[Lx(x)][Ly(y)])
#define NUMR(x,y) (num[Rx(x)][Ry(y)])


using namespace std;


struct node{
  int nu[6];
};

int RRR[10][10];
int cnt[10];


int num[300][300];
node arr[250][250][110];

int Fx(int x){
  return 100+x+1;
}
int Fy(int y){
  return 100+y;
}

int Bx(int x){
  return 100+x-1;
}
int By(int y){
  return 100+y;
}

int Rx(int x){
  return 100+x;
}
int Ry(int y){
  return 100+y+1;
}

int Lx(int x){
  return 100+x;
}
int Ly(int y){
  return 100+y-1;
}
int Mx(int x){
  return 100+x;
}
int My(int y){
  return 100+y;
}

node FlipF(node now){
  int t = now.nu[1];
  now.nu[1] = now.nu[0];
  now.nu[0] = now.nu[4];
  now.nu[4] = now.nu[3];
  now.nu[3] = t;
  return now;
}

node FlipB(node now){
  int t = now.nu[3];
  now.nu[3] = now.nu[4];
  now.nu[4] = now.nu[0];
  now.nu[0] = now.nu[1];
  now.nu[1] = t;
  return now;
}

node FlipL(node now){
  int t = now.nu[0];
  now.nu[0] = now.nu[2];
  now.nu[2] = now.nu[3];
  now.nu[3] = now.nu[5];
  now.nu[5] = t;
  return now;
}

node FlipR(node now){
  int t = now.nu[5];
  now.nu[5] = now.nu[3];
  now.nu[3] = now.nu[2];
  now.nu[2] = now.nu[0];
  now.nu[0] = t;
  return now;
}

void prrNode(node now){
  for(int i = 0;i<6;i++)printf("%d ",now.nu[i]);
  printf("\n");
}

void print()
{
  /*
  printf("M: %d F: %d B: %d R: %d L: %d\n",numM, numF, numB, numR, numL);
  prrNode(arrM[numM]);
  prrNode(arrF[numF]);
  prrNode(arrB[numB]);
  prrNode(arrR[numR]);
  prrNode(arrL[numL]);
  */

}

int main()
{
  int i,j;
  int n;
  int t,f;
  int posF;
  int x,y;
  int hei;
  RRR[1][2] = 3; RRR[1][3] = 5; RRR[1][4] = 2; RRR[1][5] = 4;
  RRR[2][1] = 4; RRR[2][3] = 1; RRR[2][4] = 6; RRR[2][6] = 3;
  RRR[3][1] = 2; RRR[3][2] = 6; RRR[3][6] = 5; RRR[3][5] = 1;
  RRR[4][1] = 5; RRR[4][5] = 6; RRR[4][6] = 2; RRR[4][2] = 1;
  RRR[5][1] = 3; RRR[5][3] = 6; RRR[5][6] = 4; RRR[5][4] = 1;
  RRR[6][2] = 4; RRR[6][4] = 5; RRR[6][5] = 3; RRR[6][3] = 2;

  while(scanf("%d",&n)!=EOF){
    if(!n)break;
    memset(num,0,sizeof(num));

    for(i=0;i<n;i++){
      scanf("%d%d",&t,&f);
      node now;
      now.nu[0] = t; now.nu[3] = 7-t;
      now.nu[1] = f; now.nu[4] = 7-f;
      now.nu[2] = RRR[t][f]; now.nu[5] = 7-RRR[t][f];


      x = 0; y = 0;
      ++num[Mx(x)][My(y)];
      hei = num[Mx(x)][My(y)];
      arr[Mx(x)][My(y)][hei] = now;


      while(1){
        posF = -1;
        if(NUMM(x,y)-NUMF(x,y)>1){
          if(posF==-1 || now.nu[1] > now.nu[posF])posF = 1;
        }
        if(NUMM(x,y)-NUMR(x,y)>1){
          if(posF==-1 || now.nu[2] > now.nu[posF])posF = 2;
        }

        if(NUMM(x,y)-NUMB(x,y)>1){
          if(posF==-1 || now.nu[4] > now.nu[posF])posF = 4;
        }

        if(NUMM(x,y)-NUML(x,y)>1){
          if(posF==-1 || now.nu[5] > now.nu[posF])posF = 5;
        }
        if(posF<1 || now.nu[posF]<4)break;

        if(posF==1){
          now = FlipF(now);
          --num[Mx(x)][My(y)];
          ++num[Fx(x)][Fy(y)];
          arr[Fx(x)][Fy(y)][NUMF(x,y)] = now;
          x++;
          y;

        }
        if(posF==2){
          now = FlipR(now);
          --num[Mx(x)][My(y)];
          ++num[Rx(x)][Ry(y)];
          arr[Rx(x)][Ry(y)][NUMR(x,y)] = now;
          x;
          y++;
        }

        if(posF==4){
          now = FlipB(now);
          --num[Mx(x)][My(y)];
          ++num[Bx(x)][By(y)];
          arr[Bx(x)][By(y)][NUMB(x,y)] = now;
          x--;
          y;

        }
        if(posF==5){
          now = FlipL(now);
          --num[Mx(x)][My(y)];
          ++num[Lx(x)][Ly(y)];
          arr[Lx(x)][Ly(y)][NUML(x,y)] = now;
          x;
          y--;
        }
        //prrNode(arr[Mx(x)][My(y)][NUMM(x,y)]);
      }
    }
    memset(cnt,0,sizeof(cnt));
    for(i=0;i<300;i++){
      for(j=0;j<300;j++){
        int t = num[i][j];
        if(t){
          cnt[ arr[i][j][t].nu[0] ]++;
        }
      }
    }
    for(i=1;i<=6;i++){
      if(i!=1)printf(" ");
      printf("%d",cnt[i]);
    }
    printf("\n");

  }
  return 0;
}

Measured memory_bytes: 7544