#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int sr[6][4]= { {4,2,3,5},
		{4,6,3,1},
		{6,5,1,2},
		{1,5,6,2},
		{4,1,3,6},
		{2,4,5,3}};

struct Dice{
  int f[3]={}; // top, front, right
  int h;
  Dice()
  {
    memset(f, 0,sizeof(f));
    h = 0;
  }
  Dice(int _t, int _f, int _h)
  {
    f[0] = _t;
    f[1] = _f;
    rep(i, 4) if(sr[_t-1][i] == _f) f[2] = sr[_t-1][(i+1)%4];
    h = _h;
  }

  int d_num(int i)
  {
    int ele[4] = {};
    ele[0] = f[1]; ele[1] = 7 - f[1];
    ele[2] = f[2]; ele[3] = 7 - f[2];
    return ele[i];
  }

  int top()
  {
    return f[0];
  }

  void fall(int x)
  {
    h = x;
  }

  void role(int d)
  {
    //    cout << d << endl;
    switch(d){
    case 0:
      to_front();
      break;
    case 1:
      to_back();
      break;
    case 2:
      to_left();
      break;
    case 3:
      to_right();
      break;
    }
  }

  void to_front()
  {
    int tmp = f[1];
    f[1] = f[0];
    f[0] = 7 - tmp;
  }
  void to_back()
  {
    int tmp = f[0];
    f[0] = f[1];
    f[1] = 7 - tmp;
  }
  void to_left()
  {
    int tmp = f[2];
    f[2] = f[0];
    f[0] = 7 - tmp;
  }
  void to_right()
  {
    int tmp = f[0];
    f[0] = f[2];
    f[2] = 7 - tmp;
  }
};

Dice field[100][100];
int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
int N;

int role(Dice &d, int x, int y)
{
  int ret = -1;
  int fall = -1;
  rep(i,4){
    int n = d.d_num(i);
    //    cout << n << endl;
    if(n < 4) continue;
    //    cout << d.h << " " << field[x+dx[i]][y+dy[i]].h << endl;
    if(d.h - field[x+dx[i]][y+dy[i]].h <= 1) continue;
    //    cout << d.d_num(ret) << " " << n << endl;
    if(ret == -1 || d.d_num(ret) < n){
      ret = i;
      fall = field[x+dx[i]][y+dy[i]].h+1; 
      //      cout << ret << endl;
    }
  }
  //  cout << endl;
  //  cout << ret << endl;
  //  cout << d.top() << endl;;
  if(ret != -1){
    d.fall(fall);
    d.role(ret);
  }
  return ret;
}

int main()
{
  while(1){
    cin >> N;
    if(N == 0) return 0;
    rep(i, 100) rep(j,100) field[i][j] = Dice();
    rep(i, N){
      int t, f; cin >> t >> f;
      int x=50, y=50;
      Dice dice(t, f, field[x][y].h+1);
      while(1){
	//	if(i==15) cout << t << " " << f<< endl;	
	int d = role(dice, x, y);
	//	if(i==15) cout << endl;
	if(d == -1) break;
	x += dx[d]; y += dy[d];
	//	if(i==16) cout << x << " " << y << " " << dice.top() << dice.h << endl;
      }
      //      cout << x << " " << y << " " << dice.top() << " " << dice.h<< endl;
      field[x][y]=dice;
    }

    int res[6] = {};
    rep(i, 100) rep(j, 100){
      if(field[i][j].h)res[field[i][j].top()-1]++; 
    }
    rep(i, 6) cout << res[i] << (i==6-1?"\n":" ");
  }
  return 0;
}

Measured memory_bytes: 3236