#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
 
const int TO = 4, BO = 5, F = 0, B = 1, R = 2, L = 3; 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int OFS = 100;
struct dice
{
    int die[6];
};

void printd(dice d)
{
    cout << d.die[TO] << endl;
    cout << d.die[F] << " " << d.die[R] << " " << d.die[B] << " " << d.die[L] << endl;
    cout << d.die[BO] << endl;
}
 
int right(int t, int f)
{
    if(t == 1)
        {if(f == 2)return 3; if(f == 3) return 5; if(f == 4) return 2;
        if(f == 5)return 4;}
    if(t == 2)
        {if(f == 1)return  4; if(f == 4) return 6; if(f == 6) return 3;
        if(f == 3)return 1 ; }
    if(t == 3)
        {if(f == 1)return 2; if(f == 2) return 6; if(f == 6) return 5;
        if(f == 5)return 1; }
    if(t == 4)
        {if(f == 1)return 5; if(f == 5) return 6; if(f == 6) return 2;
        if(f == 2)return 1; }
    if(t == 5)
        {if(f == 1)return 3; if(f == 3) return 6; if(f == 6) return 4;
        if(f == 4)return 1; }
    if(t == 6)
        {if(f == 2)return 4; if(f == 4) return 5; if(f == 5) return 3;
        if(f == 3)return 2; }
}
 
void roll(dice* d, int vec)
{
    int t;
    if(vec == F)
    {
        t = d->die[F];
        d->die[F] = d->die[TO];
        d->die[TO] = d->die[B];
        d->die[B] = d->die[BO];
        d->die[BO] = t;
    }
    if(vec == R)
    {
        t = d->die[R];
        d->die[R] = d->die[TO];
        d->die[TO] = d->die[L];
        d->die[L] = d->die[BO];
        d->die[BO] = t;
    }
    if(vec == L)
    {
        t = d->die[L];
        d->die[L] = d->die[TO];
        d->die[TO] = d->die[R];
        d->die[R] = d->die[BO];
        d->die[BO] = t;
    }
    if(vec == B)
    {
        t = d->die[B];
        d->die[B] = d->die[TO];
        d->die[TO] = d->die[F];
        d->die[F] = d->die[BO];
        d->die[BO] = t;
    }
};
 
const int W = 210;
typedef pair<int, int> pp;
 
int main()
{
    int n;
    while(cin >> n && n)
    {
        int tops[W][W] = {}, h[W][W] = {};
        REP(n)
        {
            int t, f;
            cin >> t >> f;
            dice tmp;
            tmp.die[TO] = t; tmp.die[F] = f; tmp.die[R] = right(t, f);
            tmp.die[L] = 7 - tmp.die[R]; tmp.die[B] = 7 - tmp.die[F];
            tmp.die[BO] = 7 - tmp.die[TO];
            int x = OFS; int y = OFS; int nowh = h[x][y]; int rollf = 1;
            //cout << "initialized  " << endl;
            while(rollf)
            {
                //printd(tmp);
                rollf = 0;
                vector<pp> r;
                r.push_back(pp( -tmp.die[F], F));r.push_back(pp(-tmp.die[R], R));
                r.push_back(pp( -tmp.die[B], B));r.push_back(pp(-tmp.die[L], L));
                sort(all(r));
                rep(j,4) if(nowh > h[x + dx[r[j].second]][y + dy[r[j].second]] &&
                        -r[j].first >= 4)
                {
                    roll(&tmp, r[j].second);
                    rollf = 1;
                    x += dx[r[j].second]; y += dy[r[j].second]; nowh = h[x][y];
                    break;
                }
                //cout << x << " " << y << endl;
            }
            h[x][y]++; tops[x][y] = tmp.die[TO];
        }

        //rep(j,30){rep(i,30) cout << tops[i + 85][j + 85]; cout << endl;}

        //cout << "rolled " << endl;
        int ans[7] = {};
        rep(i, W)rep(j,W) ans[tops[i][j]]++;
        cout<<ans[1]<<" "<<ans[2]<<" "<<ans[3]<<" "
            <<ans[4]<<" "<<ans[5]<<" "<<ans[6]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1548