//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};

int h[205][205], a[205][205][100];
int dice[6][6][4] = {
  {{-1, -1, -1, -1}, {2, 4, 5, 3}, {3, 2, 4, 5}, {4, 5, 3, 2}, {5, 3, 2, 4}, {-1, -1, -1, -1}}
  ,{{1, 3, 6, 4}, {-1, -1, -1, -1}, {3, 6, 4, 1}, {4, 1, 3, 6}, {-1, -1, -1, -1}, {6, 4, 1, 3}}
  ,{{1, 5, 6, 2}, {2, 1, 5, 6}, {-1,-1,-1,-1}, {-1,-1,-1,-1}, {5, 6, 2, 1}, {6, 2, 1, 5}}
  ,{{1, 2, 6, 5}, {2, 6, 5, 1}, {-1,-1,-1,-1}, {-1,-1,-1,-1}, {5, 1, 2, 6}, {6, 5, 1, 2}}
  ,{{1, 4, 6, 3}, {-1,-1,-1,-1}, {3, 1, 4, 6}, {4, 6, 3, 1}, {-1,-1,-1,-1}, {6, 3, 1, 4}}
  ,{{-1,-1,-1,-1}, {2, 3, 5, 4}, {3, 5, 4, 2}, {4, 2, 3, 5}, {5, 4, 2, 3}, {-1,-1,-1,-1}}};
signed main(void)
{
  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    REP(i, 205) REP(j, 205) {
      h[i][j] = 0;
      REP(k, 100) a[i][j][k] = 0;
    }
    REP(i, n) {
      //cout << i << endl;
      int t, f;
      cin >> t >> f;
      int x = 100, y = 100;
      while(true) {
        int th = h[y][x];
        int ans = -1, dir = -1;
        //cout << "x:" << x << " y:" << y << " th:" << th << " t:" << t << " f:" << f << endl;
        //4???????????????????????????????¢??????????
        REP(j, 4) {
          //cout << dice[t-1][f-1][j] << endl;
          //????????????????????????th????????????????????¨??????
          if(h[y+dy[j]][x+dx[j]] >= th) continue;
          //????????????????????????????????¢???4~6??§????????¨??????
          if(4 <= dice[t-1][f-1][j] && dice[t-1][f-1][j] <= 6) {
            if(dice[t-1][f-1][j] > ans) {
              ans = dice[t-1][f-1][j];
              dir = j;
            }
          }
        }
        //cout << "ans:" << ans << " dir:" << dir << endl;
        //dir??????????????¨???
        if(dir == -1) {
          a[y][x][h[y][x]] = t;
          h[y][x]++;
          break;
        } else {
          y += dy[dir];
          x += dx[dir];
          if(dir == 1 || dir == 3) {
            t = 7-ans;
          } else if(dir == 0){
            f = t;
            t = 7-ans;
          } else {
            f = 7-t;
            t = 7-ans;
          }
        }
      }
    }
    //cout << "end" << endl;
    int cnt[7] = {};
    REP(i, 205) REP(j, 205){
      if(h[i][j] != 0) cnt[a[i][j][h[i][j]-1]]++;
    }
    FOR(i, 1, 7) {
      cout << cnt[i];
      if(i != 6) cout << " ";
    }
    cout << endl;
  }

  return 0;
}