//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1181&lang=jp
#include<iostream>

using namespace std;

class Dice
{
public:
    Dice(){ top = front = under = height = 0; }
    Dice(int _t, int _f, int _u, int _h)
    {
        top = _t;
        front = _f;
        under = _u;
        height = _h;
    }
    int top, front;
    int under;
    int height;
};

//?????????????????????x, y
Dice dices[32][32];

int get_third_num(int _top, int _front)
{
    if(_top > _front)return 7 - get_third_num(_front, _top);

    if(_top == 1)
    {
        switch(_front)
        {
            case 2: return 3;
            case 3: return 5;
            case 4: return 2;
            case 5: return 4;
        }
    }
    if(_top == 2)
    {
        switch(_front)
        {
            case 3: return 1;
            case 4: return 6;
            case 6: return 3;
        }
    }
    if(_top == 3)
    {
        switch(_front)
        {
            case 5: return 1;
            case 6: return 5;       
        }
    }
    if(_top == 4)
    {
        switch(_front)
        {
            case 5: return 6;
            case 6: return 2;       
        }        
    }
    if(_top == 5)if(_front == 6)return 4;
    //cout << "error? : " << _top << " : " <<  _front << endl;

    return 1010;
}

void roll_dice(int _x, int _y)
{
    // 6 to 4
    for(int num = 6; num >= 4; num--)
    {   //top ??¨ 7-top ??\???????¨??????\???
        if( num != dices[_x][_y].top && num != (7 - dices[_x][_y].top) )
         {
            //??¢??????????????§?¨?????¨????
            int dx = 0;
            int dy = 0;

            if(dices[_x][_y].front == num)
            {
                dy = 1;
            }
            else if(7 - dices[_x][_y].front == num)
            {
                dy = -1;
            }
            else if(get_third_num(dices[_x][_y].top, dices[_x][_y].front) == num)
            {
                dx = 1;
            }
            else if(7 - get_third_num(dices[_x][_y].top, dices[_x][_y].front) == num)
            {
                dx = -1;
            }
            else continue;

            int roll_x = _x + dx;
            int roll_y = _y + dy;

            //*
            if(roll_x < 0 || roll_y < 0 || roll_x >= 32 || roll_y >= 32)
            {
                //cout << "error? ?\n?\n?\n?\n";
                return;
            }
            //*/

            if(dices[_x][_y].height - dices[roll_x][roll_y].height >= 2)
            {
                int nextFront = 0;
                if(dy == 0)nextFront = dices[_x][_y].front;
                if(dy == 1)nextFront = dices[_x][_y].top;
                if(dy == -1)nextFront = 7 - dices[_x][_y].top;

                //??¢??????
                Dice next_dice = Dice(7 - num, nextFront, dices[roll_x][roll_y].top, dices[roll_x][roll_y].height + 1);

                dices[roll_x][roll_y] = next_dice;
                dices[_x][_y] = Dice(dices[_x][_y].under, 0, 0, dices[_x][_y].height - 1);

                roll_dice(roll_x, roll_y);
            }                        
        }
    }
}

int main()
{
    int n = 0;

    while(cin >> n, n)
    {
        //???????????§?¨?
        const int cx = 15;
        const int cy = 15;

        Dice zero(0, 0, 0, 0);
        for(int i = 0; i < 32; i++)
        {
            for(int j = 0; j < 32; j++)
            {
                dices[i][j] = zero;
            }
        }


        for (int i = 0; i < n; i++)
        {
            int top, front;
            cin >> top >> front;

            Dice dice = Dice( top, front, dices[cx][cy].top, dices[cx][cy].height + 1 );
            dices[cx][cy] = dice;

            roll_dice(cx, cy);
        }

        int ans[7] = {};
        for(int i = 0; i < 32; i++)
        {
            for(int j = 0; j < 32; j++)
            {
                if(dices[i][j].top == 0)continue;
                ans[dices[i][j].top]++;
            }
        }
        for(int i = 0; i < 5; i++)
        {
            cout << ans[i + 1] << " ";
        }
        cout << ans[6] << endl;
    }

    return 0;
}

Measured memory_bytes: 3056