#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct Dice{
  int s[6];  
  int top()   {return s[0];}
  int south() {return s[1];}
  int east()  {return s[2];} 
  int west()  {return s[3];}
  int north() {return s[4];} 
  int bottom(){return s[5];}
  void roll(char c){
    //the view from above
    // N
    //W E
    // S
    string b("EWNSRL");
    int v[6][4]={{0,3,5,2},
                 {0,2,5,3},
                 {0,1,5,4},
                 {0,4,5,1},
                 {1,2,4,3},
                 {1,3,4,2}};
    for(int k=0;k<6;k++){
      if(b[k]!=c) continue;
      int t=s[v[k][0]];
      s[v[k][0]]=s[v[k][1]];
      s[v[k][1]]=s[v[k][2]];
      s[v[k][2]]=s[v[k][3]];
      s[v[k][3]]=t;
    }
  }
  using ll = long long;
  ll hash(){
    ll res=0;
    for(int i=0;i<6;i++) res=res*256+s[i];
    return res;
  }
  bool operator==(const Dice &d) const{
    for(int i=0;i<6;i++) if(s[i]!=d.s[i]) return 0;
    return 1;
  }
};
vector<Dice> makeDices(Dice d){
  vector<Dice> res;
  for(int i=0;i<6;i++){
    Dice t(d);
    if(i==1) t.roll('N'); 
    if(i==2) t.roll('S'); 
    if(i==3) t.roll('S'),t.roll('S');
    if(i==4) t.roll('L'); 
    if(i==5) t.roll('R'); 
    for(int k=0;k<4;k++){
      res.push_back(t);
      t.roll('E');
    }
  }
  return res;
}

int height[200][200];
int ans[7];
int most[200][200];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    Dice tmp;
    for(int i = 0; i < 6; i++) tmp.s[i] = i + 1;
    vector<Dice> Dices = makeDices(tmp);
    while(true) {
        int N;
        cin >> N;
        if(N == 0) break;
        for(int h = 0; h < 200; h++) {
            for(int w = 0; w < 200; w++) height[h][w] = 0, most[h][w] = 0;
        }
        for(int i = 1; i <= 6; i++) ans[i] = 0;
        while(N--) {
            int t, f;
            cin >> t >> f;
            Dice now;
            for(int i = 0; i < Dices.size(); i++) {
                if(Dices[i].top() == t && Dices[i].south() == f) now = Dices[i];
            }
            int nowh = 100;
            int noww = 100;
            while(true) {
                char direc = '#';
                int val = -1;
                if(height[nowh][noww] > height[nowh-1][noww] && now.south() > val) {
                    direc = 'S';
                    val = now.south();
                }
                if(height[nowh][noww] > height[nowh][noww+1] && now.east() > val) {
                    direc = 'E';
                    val = now.east();
                }
                if(height[nowh][noww] > height[nowh][noww-1] && now.west() > val) {
                    direc = 'W';
                    val = now.west();
                }
                if(height[nowh][noww] > height[nowh+1][noww] && now.north() > val) {
                    direc = 'N';
                    val = now.north();
                }
                if(val <= 3) break;
                now.roll(direc);
                if(direc == 'S') {
                    nowh--;
                }
                if(direc == 'W') {
                    noww--;
                }
                if(direc == 'E') {
                    noww++;
                }
                if(direc == 'N') {
                    nowh++;
                }
            }
            height[nowh][noww]++;
            most[nowh][noww] = now.top();
        }
        for(int h = 0; h < 200; h++) {
            for(int w = 0; w < 200; w++) {
                ans[most[h][w]]++;
            }
        }
        for(int i = 1; i <= 6; i++) {
            cout << ans[i];
            if(i < 6) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3544