#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)

#define NO 0
#define UP 1
#define RIGHT 2
#define LEFT 3
#define DOWN 4

int h[201][201], face[201][201];
const int six[7][7] = {
    {NO, NO, NO, NO, NO, NO, NO},
    {NO, NO, NO, NO, NO, NO, NO},
    {NO, UP, NO, LEFT, RIGHT, NO, DOWN},
    {NO, UP, RIGHT, NO, NO, LEFT, DOWN},
    {NO, UP, LEFT, NO, NO, RIGHT, DOWN},
    {NO, UP, NO, RIGHT, LEFT, NO, DOWN},
    {NO, NO, NO, NO, NO, NO, NO}
};
const int five[7][7] = {
    {NO, NO, NO, NO, NO, NO, NO},
    {NO, NO, UP, RIGHT, LEFT, DOWN, NO},
    {NO, NO, NO, NO, NO, NO, NO},
    {NO, LEFT, UP, NO, NO, DOWN, RIGHT},
    {NO, RIGHT, UP, NO, NO, DOWN, LEFT},
    {NO, NO, NO, NO, NO, NO, NO},
    {NO, NO, UP, LEFT, RIGHT, DOWN, NO}
};
const int four[7][7] = {
    {NO, NO, NO, NO, NO, NO, NO},
    {NO, NO, LEFT, UP, DOWN, RIGHT, NO},
    {NO, RIGHT, NO, UP, DOWN, NO, LEFT},
    {NO, NO, NO, NO, NO, NO, NO},
    {NO, NO, NO, NO, NO, NO, NO},
    {NO, LEFT, NO, UP, DOWN, NO, RIGHT},
    {NO, NO, RIGHT, UP, DOWN, LEFT, NO}
};
int main(void){
    int n;
    while(cin >> n && n) {
        int t, f;
        rep(i, 201) rep(j, 201) {h[i][j] = 0; face[i][j] = -1;}
        rep(i, n) {
            cin >> t >> f;
            t; f;
            int x = 100, y = 100;
            int nx, ny;
            h[y][x]++;
            bool fall = true;
            while(fall) {
                nx = x;
                ny = y;
                fall = false;
                if(six[t][f] == UP && h[y+1][x] < h[y][x]-1) {
                    fall = true;
                    ny = y+1;
                    f = 7-t; t = 1; 
                } else if(six[t][f] == RIGHT && h[y][x+1] < h[y][x]-1) {
                    fall = true;
                    nx = x+1;
                    t = 1;
                } else if(six[t][f] == LEFT && h[y][x-1] < h[y][x]-1) {
                    fall = true;
                    nx = x-1;
                    t = 1;
                } else if(six[t][f] == DOWN && h[y-1][x] < h[y][x]-1) {
                    fall = true;
                    ny = y-1;
                    f = t; t = 1; 
                } else if(five[t][f] == UP && h[y+1][x] < h[y][x]-1) {
                    fall = true;
                    ny = y+1;
                    f = 7-t; t = 2;
                } else if(five[t][f] == RIGHT && h[y][x+1] < h[y][x]-1) {
                    fall = true;
                    nx = x+1;
                    t = 2;
                } else if(five[t][f] == LEFT && h[y][x-1] < h[y][x]-1) {
                    fall = true;
                    nx = x-1;
                    t = 2;
                } else if(five[t][f] == DOWN && h[y-1][x] < h[y][x]-1) {
                    fall = true;
                    ny = y-1;
                    f = t; t = 2;
                } else if(four[t][f] == UP && h[y+1][x] < h[y][x]-1) {
                    fall = true;
                    ny = y+1;
                    f = 7-t; t = 3;
                } else if(four[t][f] == RIGHT && h[y][x+1] < h[y][x]-1) {
                    fall = true;
                    nx = x+1;
                    t = 3;
                } else if(four[t][f] == LEFT && h[y][x-1] < h[y][x]-1) {
                    fall = true;
                    nx = x-1;
                    t = 3;
                } else if(four[t][f] == DOWN && h[y-1][x] < h[y][x]-1) {
                    fall = true;
                    ny = y-1;
                    f = t; t = 3;
                }
                if(fall) {
                    h[y][x]--;
                    h[ny][nx]++;
                    x = nx; y = ny;
                }
                else {
                }
            }
            face[y][x] = t;
        }
        int ans[6] = {};
        rep(i, 201) rep(j, 201) {if(face[i][j] != -1) ans[face[i][j]-1]++;}
        cout << ans[0];
        rep(i, 5) cout << " " << ans[i+1];
        cout << endl;
    }
}

Measured memory_bytes: 1480