#include<iostream>
#include<complex>

using namespace std;

typedef complex<int> C;

int dice[6][4] = {{3, 2, 4, 5}, {1, 3, 6, 4}, {1, 5, 6, 2},
                    {1, 2, 6, 5}, {1, 4, 6, 3}, {2, 3, 5, 4}};

C transfer(int t, int f, int d) {
    if (t == d || t+d == 7) {
        return C(0, 0);
    }
    else if (f == d) {
        return C(0, -1);
    }
    else if (f+d == 7) {
        return C(0, 1);
    }
    else {
        for (int i=0; i<3; i++) {
            if (t == dice[d-1][i] && f == dice[d-1][i+1]) {
                return C(-1, 0);
            }
        }
        if (t == dice[d-1][3] && f == dice[d-1][0]) {
            return C(-1, 0);
        }
        else {
            return C(1, 0);
        }
    }
}

int main() {
    int n, t, f;
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        int top[400][400] = {};
        int height[400][400] = {};
        for (int i=0; i<n; i++) {
            cin >> t >> f;
            C pos = C(200, 200);
            bool is_transferred = true;
            while (is_transferred) {
                is_transferred = false;
                for (int d=6; d>3; d--) {
                    C moved = pos+transfer(t, f, d);
                    if (height[pos.real()][pos.imag()] > height[moved.real()][moved.imag()]) {
                        is_transferred = true;
                        pos = moved;
                        if (f == d) {
                            f = t;
                        }
                        else if (f+d == 7) {
                            f = 7-t;
                        }
                        t = 7-d;
                        break;
                    }
                }
            }
            top[pos.real()][pos.imag()] = t;
            height[pos.real()][pos.imag()]++;
            //cout << "pos=" << pos << ", t=" << t << ", f=" << f << ", h=" << height[pos.real()][pos.imag()] << endl;
        }
        int count[7] = {};
        for (int i=0; i<400; i++) {
            for (int j=0; j<400; j++) {
                count[top[i][j]]++;
            }
        }
        for (int i=1; i<=6; i++) {
            cout << count[i];
            if (i == 6) {
                cout << endl;
            }
            else {
                cout << ' ';
            }
        }
    }
    return 0;
}