#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

class Dice{
    public:
        vector<int> d;
        Dice(int u,int f) : d(6) {
            d[0] = u;
            d[1] = f;
            d[3] = 7-u;
            d[4] = 7-f;
            d[2] = getside(u,f);
            d[5] = 7-d[2];
        }

        int getside(int u,int f){
            int side[6][4] = {{2,3,5,4},{1,4,6,3},{1,2,6,5},{1,5,6,2},{1,3,6,4},{2,4,5,3}};
            for(int i=0;i<4;i++){
                if(side[u-1][i]==f) return side[u-1][(i+1)%4];
            }
        }

        Dice move(int n){
            if(n==0){
                return Dice(d[4],d[0]);
            }else if(n==1){
                return Dice(d[5],d[1]);
            }else if(n==2){
                return Dice(d[1],d[3]);
            }else if(n==3){
                return Dice(d[2],d[1]);
            }else{
                while(1){}
                assert(false);
            }
        }

        int get(int i){
            if(i==0) return d[1];
            else if(i==1) return d[2];
            else if(i==2) return d[4];
            else if(i==3) return d[5];
        }
};

void fall(int x,int y,Dice dice,vvi& high,vvi& table){
    //cerr << "Fall (" << x << "," << y << ") side : " << dice.d << endl;
    bool f=false;
    [&](){
        for(int i=6;i>=4;i--) for(int j=0;j<4;j++){
            if(i==dice.get(j) && high[x][y]-high[x+dx[j]][y+dy[j]]>0){
                //cerr << "Face --> i=" << i << " get(j):" << dice.get(j) << endl;
                fall(x+dx[j],y+dy[j],dice.move(j),high,table);
                f=true;
                return;
            }
        }
    }();
    if(!f){
        high[x][y]++;
        table[x][y]=dice.d[0];
    }

}

void solve(int n){
    vector<vector<int>> high(200,vector<int>(200,0));
    vector<vector<int>> table(200,vector<int>(200,0));
    const int x=100,y=100;

    rep(loop,n){
//        cerr << "loop"<<loop<<" ------------------" << endl;
        int u,f;
        cin>>u>>f;
        Dice dice(u,f);


        fall(x,y,dice,high,table);


        //cerr << "table ... " << endl;
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                //cerr << table[x+i][y+j] << " ";
            }
            //cerr << endl;
        }

        //cerr << "high ... " << endl;
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                //cerr << high[x+i][y+j] << " ";
            }
            //cerr << endl;
        }
    }

    vector<int> sum(7,0);
    for(int i=0;i<200;i++) for(int j=0;j<200;j++){
        sum[table[i][j]]++;
    }

    for(int i=1;i<6;i++) cout << sum[i] << " ";
    cout << sum[6] << endl;
}

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        solve(n);
    }
}

Measured memory_bytes: 3352