#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int height[200][200];
int top[200][200];
int cnt[11];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
int nei[10][10] = {{}, 
  {3, 5, 4, 2}, 
  {3, 1, 4, 6}, 
  {5, 1, 2, 6}, 
  {1, 5, 6, 2}, 
  {1, 3, 6, 4}, 
  {5, 3, 2, 4}, 
};


void Construct(vector<int> &num, int t, int f) {
  num[4] = t;
  num[5] = 7-t;
  num[1] = f;
  num[3] = 7-f;
  
  rep(idx, 4) { 
    if (nei[t][idx] == f) {
      num[2] = nei[t][(idx+1)%4];
      num[0] = nei[t][(idx+3)%4];
      break;
    }
  }
}

void Roll(vector<int> &num, int idx) {
  vector<int> ret(6);
  ret[(idx+1)%4] = num[(idx+1)%4];
  ret[(idx+3)%4] = num[(idx+3)%4];
  ret[5] = num[idx];
  ret[(idx+2)%4] = num[5];
  ret[4] = num[(idx+2)%4];
  ret[idx] = num[4];
  num = ret;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  while (1) {
    cin >> N;
    if (!N) return 0;

    fill(height[0], height[200], 0);
    fill(top[0], top[200], -1);
    rep(i, N) {
      int x = 100;
      int y = 100;

      int t, f;
      cin >> t >> f;
      vector<int> num(6);
      Construct(num, t, f);

      while (1) {
        pii mv(-1, -1);
        rep(i, 4) {
          int nx = x + dx[i];
          int ny = y + dy[i];
          if (height[ny][nx] >= height[y][x]) continue;
          if (num[i] <= 3) continue;
          MX(mv, pii(num[i], i));
        }

        if (mv.X == -1) {
          height[y][x]++;
          top[y][x] = num[4];
          break;
        }
        x += dx[mv.Y];
        y += dy[mv.Y];
        Roll(num, mv.Y);
      }
    }

    fill(cnt, cnt+10, 0);
    rep(y, 200) {
      rep(x, 200) {
        if (top[y][x] == -1) continue;
        cnt[top[y][x]]++;
      }
    }

    reps(i, 1, 7) {
      if (i > 1) cout << " ";
      cout << cnt[i];
    }
    cout << "\n";
  }
}

