#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

struct Mas
{
    int height, number;
    Mas(int h, int n) : height(h), number(n) {}
};

struct Dice
{
    int front, back, top, bottom, left, right;
    vector<int> nums; // back,right,front,left

    int x, y;

    Dice(int f, int t)
    {
        nums.assign(6, 0);
        front = f;
        top = t;
        back = 7 - f;
        bottom = 7 - t;
        if (f == 1)
        {
            if (t == 2)
            {
                right = 4;
                left = 3;
            }
            else if (t == 3)
            {
                right = 2;
                left = 5;
            }
            else if (t == 4)
            {
                right = 5;
                left = 2;
            }
            else if (t == 5)
            {
                right = 3;
                left = 4;
            }
        }
        else if (f == 2)
        {
            if (t == 1)
            {
                right = 3;
                left = 4;
            }
            else if (t == 3)
            {
                right = 6;
                left = 1;
            }
            else if (t == 4)
            {
                right = 1;
                left = 6;
            }
            else if (t == 6)
            {
                right = 4;
                left = 3;
            }
        }
        else if (f == 3)
        {
            if (t == 1)
            {
                right = 5;
                left = 2;
            }
            else if (t == 2)
            {
                right = 1;
                left = 6;
            }
            else if (t == 5)
            {
                right = 6;
                left = 1;
            }
            else if (t == 6)
            {
                right = 2;
                left = 5;
            }
        }
        else if (f == 4)
        {
            if (t == 1)
            {
                right = 2;
                left = 5;
            }
            else if (t == 2)
            {
                right = 6;
                left = 1;
            }
            else if (t == 5)
            {
                right = 1;
                left = 6;
            }
            else if (t == 6)
            {
                right = 5;
                left = 2;
            }
        }
        else if (f == 5)
        {
            if (t == 1)
            {
                right = 4;
                left = 3;
            }
            else if (t == 3)
            {
                right = 1;
                left = 6;
            }
            else if (t == 4)
            {
                right = 6;
                left = 1;
            }
            else if (t == 6)
            {
                right = 3;
                left = 4;
            }
        }
        else if (f == 6)
        {
            if (t == 2)
            {
                right = 3;
                left = 4;
            }
            else if (t == 3)
            {
                right = 5;
                left = 2;
            }
            else if (t == 4)
            {
                right = 2;
                left = 5;
            }
            else if (t == 5)
            {
                right = 4;
                left = 3;
            }
        }
        nums[0] = back;
        nums[1] = right;
        nums[2] = front;
        nums[3] = left;
        nums[4] = top;
        nums[5] = bottom;

        x = 100;
        y = 100;
    }

    bool rotate(vector<vector<Mas>> &field)
    {
        int max_num = -1;
        int dir = -1;
        for (int i = 0; i < 4; i++) // ↑→↓←
        {
            int nx = x + dx[i], ny = y + dy[i];
            if (field[ny][nx].height < field[y][x].height)
            {
                if (nums[i] == 4 || nums[i] == 5 || nums[i] == 6)
                {
                    if (max_num < nums[i])
                    {
                        max_num = nums[i];
                        dir = i;
                    }
                }
            }
        }

        if (dir == -1)
        {
            return false;
        }
        else
        {
            vector<int> new_nums = nums;
            if (dir == 0)
            {
                new_nums[5] = nums[0];
                new_nums[0] = nums[4];
                new_nums[4] = nums[2];
                new_nums[2] = nums[5];
                nums = new_nums;
                y++;
            }
            else if (dir == 1)
            {
                new_nums[5] = nums[1];
                new_nums[1] = nums[4];
                new_nums[4] = nums[3];
                new_nums[3] = nums[5];
                nums = new_nums;
                x++;
            }
            else if (dir == 2)
            {
                new_nums[5] = nums[2];
                new_nums[2] = nums[4];
                new_nums[4] = nums[0];
                new_nums[0] = nums[5];
                nums = new_nums;
                y--;
            }
            else if (dir == 3)
            {
                new_nums[5] = nums[3];
                new_nums[3] = nums[4];
                new_nums[4] = nums[1];
                new_nums[1] = nums[5];
                nums = new_nums;
                x--;
            }
        }
        return true;
    }
};

int main()
{
    int N;
    while (cin >> N, N)
    {
        vector<vector<Mas>> field(200, vector<Mas>(200, Mas(0, 0)));
        // field[y][x] := pair(高さ,topの数)

        for (int i = 0; i < N; i++)
        {
            int t, f;
            cin >> t >> f;

            Dice D(f, t);
            while (D.rotate(field))
            {
            };
            field[D.y][D.x] = Mas(field[D.y][D.x].height + 1, D.nums[4]);
        }
        vector<int> res(6);
        for (int i = 0; i < 200; i++)
        {
            for (int j = 0; j < 200; j++)
            {
                if (field[i][j].height >= 1)
                {
                    res[field[i][j].number - 1]++;
                }
            }
        }
        for (int i = 0; i < 6; i++)
        {
            cout << res[i] << (i == 5 ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 3244