#include <iostream>
#include <cstring>
using namespace std;

#define N 200
int h[N][N];
int top[N][N];
int R[6][6];
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};
class Dice{
public:
  int t,f,r,x,y,z;
  Dice(int a,int b){
    t = a;
    f = b;
    r = R[a][b];
    x = y = N/2;
    z = h[y][x];
  }
  int movedir(){
    int num[] = {5-f,r,f,5-r};
    int ret = -1;
    int maxnum = 2;
    for(int i=0;i<4;++i){
      if(maxnum < num[i] && h[y+dy[i]][x+dx[i]] < h[y][x]){
	maxnum = num[i];
	ret = i;
      }
    }
    return ret;
  }
  void rot(int dir){
    if(dir==-1) return;
    if(dir==0){
      int tmp = t;
      t = f;
      f = 5-tmp;
    }
    if(dir==1){
      int tmp = t;
      t = 5-r;
      r = tmp;
    }
    if(dir==2){
      int tmp = t;
      t = 5-f;
      f = tmp;
    }
    if(dir==3){
      int tmp = t;
      t = r;
      r = 5-tmp;
    }
    x+=dx[dir];
    y+=dy[dir];
    z = h[y][x];
  }
  void move(){
    while(true){
      int d = movedir();
      if(d==-1) break;
      rot(d);
    }
    h[y][x]++;
    top[y][x]=t;
  }
};

int main(){
  string s[] = {"-2413-",
		"3-05-2",
		"15--04",
		"40--51",
		"2-50-3",
		"-3142-"};
  for(int i=0;i<6;++i)
    for(int j=0;j<6;++j)
      if(s[i][j]!='-')
	R[i][j] = s[i][j]-'0';
  int n;
  while(cin>>n,n){
    memset(top,-1,sizeof(top));
    memset(h,0,sizeof(h));
    for(int i=0;i<n;++i){
      int t,f;
      cin >> t >> f;
      t--;
      f--;
      Dice d = Dice(t,f);
      d.move();
    }
    int hist[6]={};
    for(int i=0;i<N;++i)
      for(int j=0;j<N;++j)
	if(top[i][j]>=0) hist[top[i][j]]++;
    for(int i=0;i<5;++i) cout << hist[i] << " ";
    cout << hist[5] << endl;
  }
  return 0;
}