#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define rep(a, b, c) for(int a = b; a < c; a++)

using namespace std;

class Filed {
public:
    int h;
    int m;

    void set(int h, int m);
};

void Filed::set(int h, int m) {
    this->h = h;
    this->m = m;
}
Filed filed[100][100];

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

void put(int t, int f, int x, int y) {
    int h = filed[x][y].h;
    if (h == 0) {
        filed[x][y].set(h + 1, t);
        return;
    }
    int saikoro_index;
    rep(i, 0, 4) {
        if (saikoro[t][i] == f) {
            saikoro_index = i;
            break;
        }
    }
    int next_x, next_y, next_t, next_f;
    int roll_m = 0;
    rep(i, 0, 4) {
        int index = (i + saikoro_index) % 4;
        int m = saikoro[t][index];
        if (m <= 3 || m < roll_m) {
            continue;
        }
        switch(i) {
            case 0:
                if (filed[x][y - 1].h < h) {
                    next_x = x;
                    next_y = y - 1;
                    next_t = saikoro[t][(index + 2) % 4];
                    next_f = t;
                    roll_m = m;
                }
                break;
            case 1:
                if (filed[x - 1][y].h < h) {
                    next_x = x - 1;
                    next_y = y;
                    next_t = saikoro[t][(index + 2) % 4];
                    next_f = f;
                    roll_m = m;
                }
                break;
            case 2:
                if (filed[x][y + 1].h < h) {
                    next_x = x;
                    next_y = y + 1;
                    next_t = saikoro[t][(index + 2) % 4];
                    next_f = 7 - t;
                    roll_m = m;
                }
                break;
            case 3:
                if (filed[x + 1][y].h < h) {
                    next_x = x + 1;
                    next_y = y;
                    next_t = saikoro[t][(index + 2) % 4];
                    next_f = f;
                    roll_m = m;
                }
                break;
        }
    }
    if (roll_m == 0) {
        filed[x][y].set(h + 1, t);
        return;
    }
    put(next_t, next_f, next_x, next_y);
}


int main() {
    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        rep(i, 0, 100) {
            rep(j, 0, 100) {
                filed[i][j].set(0, 0);
            }
        }
        rep(i, 0, N) {
            int T, F;
            cin >> T >> F;
            put(T, F, 50, 50);
        }
        vector<int> counter(7, 0);
        rep(i, 0, 100) {
            rep(j, 0, 100) {
                if (filed[i][j].m != 0) {
                    counter[filed[i][j].m]++;
                }
            }
        }
        rep(i, 0, 6) {
            cout << counter[i + 1];
            if (i != 5) {
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}