#include <iostream>
#include <vector>
using namespace std;


enum {
    TOP = 0,
    FRONT,
    RIGHT,
    LEFT,
    BACK,
    BOTTOM
};

class dice {
public:
    dice(int top, int front) 
        : v_(6)
    {
        int right[7][7] = {};
        // change 
        right[1][2] = 3; right[1][3] = 5; right[1][4] = 2; right[1][5] = 4;
        right[2][1] = 4; right[2][3] = 1; right[2][4] = 6; right[2][6] = 3;
        right[3][1] = 2; right[3][2] = 6; right[3][5] = 1; right[3][6] = 5;
        right[4][1] = 5; right[4][2] = 1; right[4][5] = 6; right[4][6] = 2;
        right[5][1] = 3; right[5][3] = 6; right[5][4] = 1; right[5][6] = 4;
        right[6][2] = 4; right[6][3] = 2; right[6][4] = 5; right[6][5] = 3;
        v_[TOP] = top;
        v_[FRONT] = front;
        v_[BOTTOM] = 7 - top;
        v_[BACK] = 7 - front;
        v_[RIGHT] = right[top][front];
        v_[LEFT] = 7 - v_[RIGHT];
    }
    dice(vector<int> const& v)
    : v_(v)
    {}

    dice roll(int dir) {
        vector<int> res(6);
        for(int i=0; i<6; ++i) {
            res[i] = v_[rot[dir][i]];
        }
        return dice(res);
    }

    int get(int idx) {
        if(idx < 0 || 6 <= idx) {
            return -1;
        }
        return v_[idx];
    }

private:
    std::vector<int> v_;
    int rot[6][6] = {{4, 0, 2, 3, 5, 1},  // south 
                     {3, 1, 0, 5, 4, 2},  // east
                     {2, 1, 5, 0, 4, 3},  // west
                     {1, 5, 2, 3, 0, 4},  // north 
                     {0, 2, 4, 1, 3, 5},  // right(not move)
                     {0, 3, 1, 4, 2, 5}}; // left(not move)
};


int main() {
    int N;
    while(cin >> N, N) {
        int dx[4] = {0, 1, -1, 0},
            dy[4] = {-1, 0, 0, 1};
        vector<vector<int>> high(2*N, vector<int>(2*N));
        vector<vector<int>> tp(2*N, vector<int>(2*N));
        for(int i=0; i<N; ++i) {
            int t, f;
            cin >> t >> f;
            dice d(t, f);
            high[N][N]++;
            int x = N, y = N;
            while(true) {
                int dir = -1, ma = -1;
                if(high[x][y] == 1) {
                    break;
                }
                for(int i=0; i<4; ++i) {
                    int nx = x + dx[i], ny = y + dy[i];
                    if(high[nx][ny] + 1 < high[x][y] && 4 <= d.get(i+FRONT) && d.get(i+FRONT) > ma) {
                        dir = i;
                        ma = d.get(i+FRONT);
                    }
                }
                if(dir == -1) {
                    break;
                } else {
                    int nx = x + dx[dir], ny = y + dy[dir];
                    high[x][y]--;
                    high[nx][ny]++;
                    x = nx;
                    y = ny;
                    d = d.roll(dir);
                }
            }
            tp[x][y] = d.get(TOP);
        }
        vector<int> res(6, 0);
        for(int i=0; i<tp.size(); ++i) {
            for(int j=0; j<tp[i].size(); ++j) {
                if(tp[i][j] != 0) {
                    res[tp[i][j]-1]++;
                }
            }
        }
        for(int i=0; i<res.size(); ++i) {
            cout << res[i];
            if(i != res.size()-1) {
                cout << " ";
            } else {
                cout << endl;
            }
        }
    }
}


Measured memory_bytes: 3220