#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
 
using P = pair<int, int>;
 
map<P, int> leftm;
void init() {
    leftm[make_pair(1, 2)] = 4;
    leftm[make_pair(1, 3)] = 2;
    leftm[make_pair(1, 4)] = 5;
    leftm[make_pair(1, 5)] = 3;
 
    leftm[make_pair(2, 1)] = 3;
    leftm[make_pair(2, 3)] = 6;
    leftm[make_pair(2, 4)] = 1;
    leftm[make_pair(2, 6)] = 4;
 
    leftm[make_pair(3, 1)] = 5;
    leftm[make_pair(3, 2)] = 1;
    leftm[make_pair(3, 5)] = 6;
    leftm[make_pair(3, 6)] = 2;
 
    leftm[make_pair(4, 1)] = 2;
    leftm[make_pair(4, 2)] = 6;
    leftm[make_pair(4, 5)] = 1;
    leftm[make_pair(4, 6)] = 5;
 
    leftm[make_pair(5, 1)] = 4;
    leftm[make_pair(5, 3)] = 1;
    leftm[make_pair(5, 4)] = 6;
    leftm[make_pair(5, 6)] = 3;
 
    leftm[make_pair(6, 2)] = 3;
    leftm[make_pair(6, 3)] = 5;
    leftm[make_pair(6, 4)] = 2;
    leftm[make_pair(6, 5)] = 4;
}
 
struct dice {
    int top, front, left;
    dice() {}
    dice(int t, int f) : top(t), front(f) {
        left = leftm[make_pair(t, f)];
    }
 
    dice rot_left() {
        return dice(7-left, front);
    }
 
    dice rot_right() {
        return dice(left, front);
    }
 
    dice rot_front() {
        return dice(7-front, top);
    }
 
    dice rot_back() {
        return dice(front, 7-top);
    }
 
    int side(int d) {
        assert(0 <= d && d < 4);
        if (d == 0) { return front; }
        if (d == 1) { return left; }
        if (d == 2) { return 7-front; }
        return 7-left;
    }
 
    dice rot_num(int d) {
        assert(0 <= d && d < 4);
        if (d == 0) { return rot_front(); }
        if (d == 1) { return rot_left(); }
        if (d == 2) { return rot_back(); }
        return rot_right();
    }
};
 
int N;
 
int main(){
    init();
    while(true) {
        cin >> N;
        if (N == 0) {
            break;
        }
 
        const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};
 
        map<P, int> topm;
        map<P, int> height;
        for (int j = -105; j <= 105; ++j) { for (int k =  -105; k <= 105; ++k) { height[make_pair(j, k)] = 0; } }
        for (int j = -105; j <= 105; ++j) { for (int k =  -105; k <= 105; ++k) { topm[make_pair(j, k)] = -1; } }
 
        for (int j = 0; j < N; ++j) {
            int top, front;
            cin >> top >> front;
 
            int x = 0, y = 0;
            dice dc(top, front);
 
            // cout << "------" << endl;
            while (true) {
                int nd = -1;
                for (int nk = 6; nd == -1 && nk >= 4; --nk) {
                    for (int d = 0; d < 4; ++d) {
                        if (dc.side(d) == nk) {
                            int nx = x + dx[d], ny = y + dy[d];
                            if (height[make_pair(x, y)] > height[make_pair(nx, ny)]) {
                                nd = d;
                                break;
                            }
                        }
                    }
                }
 
                if (nd == -1) {
                    break;
                }
 
                dc = dc.rot_num(nd);
                x += dx[nd]; y += dy[nd];
            }
 
            ++height[make_pair(x, y)];
            topm[make_pair(x, y)] = dc.top;
        }
 
        int ans[7] = {0, 0, 0, 0, 0, 0, 0};
        for (int j = -105; j <= 105; ++j) {
            for (int k = -105; k <= 105; ++k) {
                if (topm[make_pair(j, k)] != -1) {
                    ++ans[topm[make_pair(j, k)]];
                }
            }
        }
 
        for (int j = 1; j <= 6; ++j) {
            if (j > 1) cout << " ";
            cout << ans[j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 8652