#include<bits/stdc++.h>
using namespace std;

void sai(int &t, int &f, int &d, int & b, int & l, int & r){
    d = 7 - t;
    b = 7 - f;
    if (t == 1 && f == 2){
        r = 3;
        l = 4;
    }
    if (t == 1 && f == 3){
        r = 5;
        l = 2;
    }
    if (t == 1 && f == 4){
        r = 2;
        l = 5;
    }
    if (t == 1 && f == 5){
        r = 4;
        l = 3;
    }
    if (t == 2 && f == 1){
        r = 4;
        l = 3;
    }
    if (t == 2 && f == 3){
        r = 1;
        l = 6;
    }
    if (t == 2 && f == 4){
        r = 6;
        l = 1;
    }
    if (t == 2 && f == 6){
        r = 3;
        l = 4;
    }
    if (t == 3 && f == 1){
        r = 2;
        l = 5;
    }
    if (t == 3 && f == 2){
        r = 6;
        l = 1;
    }
    if (t == 3 && f == 5){
        r = 1;
        l = 6;
    }
    if (t == 3 && f == 6){
        r = 5;
        l = 2;
    }
    if (t == 4 && f == 1){
        r = 5;
        l = 2;
    }
    if (t == 4 && f == 2){
        r = 1;
        l = 6;
    }
    if (t == 4 && f == 5){
        r = 6;
        l = 1;
    }
    if (t == 4 && f == 6){
        r = 2;
        l = 5;
    }
    if (t == 5 && f == 1){
        r = 3;
        l = 4;
    }
    if (t == 5 && f == 3){
        r = 6;
        l = 1;
    }
    if (t == 5 && f == 4){
        r = 1;
        l = 6;
    }
    if (t == 5 && f == 6){
        r = 4;
        l = 3;
    }
    if (t == 6 && f == 2){
        r = 4;
        l = 3;
    }
    if (t == 6 && f == 3){
        r = 2;
        l = 5;
    }
    if (t == 6 && f == 4){
        r = 5;
        l = 2;
    }
    if (t == 6 && f == 5){
        r = 3;
        l = 4;
    }
}

void roll(int &t, int &f, int &d, int & b, int & l, int & r, int dir){
    int nt, nf, nd, nb, nl, nr;
    if (dir == 0){
        nt = f;
        nf = d;
        nd = b;
        nb = t;
        nl = l;
        nr = r;
    }
    if (dir == 2){
        nt = b;
        nf = t;
        nd = f;
        nb = d;
        nl = l;
        nr = r;
    }
    if (dir == 1){
        nt = l;
        nr = t;
        nd = r;
        nl = d;
        nf = f;
        nb = b;
    }
    if (dir == 3){
        nt = r;
        nr = d;
        nd = l;
        nl = t;
        nf = f;
        nb = b;
    }
    t = nt;
    f = nf;
    d = nd;
    b = nb;
    l = nl;
    r = nr;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if (!n) break;
        vector<vector<int>> block(100, vector<int>(100, 0));
        vector<vector<int>> block_height(100, vector<int>(100, 0));
        int t, f, d, b, l, r;
        for (int i = 0; i < n; i++){
            cin >> t >> f;
            sai(t, f, d, b, l, r);
            int x = 50;
            int y = 50;
            while(1){
                if (f == 6){
                    if (block_height[x][y] > block_height[x][y-1]){
                        roll(t, f, d, b, l, r, 2);
                        y--;
                        continue;
                    }
                }
                if (b == 6){
                    if (block_height[x][y] > block_height[x][y+1]){
                        roll(t, f, d, b, l, r, 0);
                        y++;
                        continue;
                    }
                }
                if (l == 6){
                    if (block_height[x][y] > block_height[x-1][y]){
                        roll(t, f, d, b, l, r, 3);
                        x--;
                        continue;
                    }
                }
                if (r == 6){
                    if (block_height[x][y] > block_height[x+1][y]){
                        roll(t, f, d, b, l, r, 1);
                        x++;
                        continue;
                    }
                }
                if (f == 5){
                    if (block_height[x][y] > block_height[x][y-1]){
                        roll(t, f, d, b, l, r, 2);
                        y--;
                        continue;
                    }
                }
                if (b == 5){
                    if (block_height[x][y] > block_height[x][y+1]){
                        roll(t, f, d, b, l, r, 0);
                        y++;
                        continue;
                    }
                }
                if (l == 5){
                    if (block_height[x][y] > block_height[x-1][y]){
                        roll(t, f, d, b, l, r, 3);
                        x--;
                        continue;
                    }
                }
                if (r == 5){
                    if (block_height[x][y] > block_height[x+1][y]){
                        roll(t, f, d, b, l, r, 1);
                        x++;
                        continue;
                    }
                }
                if (f == 4){
                    if (block_height[x][y] > block_height[x][y-1]){
                        roll(t, f, d, b, l, r, 2);
                        y--;
                        continue;
                    }
                }
                if (b == 4){
                    if (block_height[x][y] > block_height[x][y+1]){
                        roll(t, f, d, b, l, r, 0);
                        y++;
                        continue;
                    }
                }
                if (l == 4){
                    if (block_height[x][y] > block_height[x-1][y]){
                        roll(t, f, d, b, l, r, 3);
                        x--;
                        continue;
                    }
                }
                if (r == 4){
                    if (block_height[x][y] > block_height[x+1][y]){
                        roll(t, f, d, b, l, r, 1);
                        x++;
                        continue;
                    }
                }
                block_height[x][y]++;
                block[x][y] = t;

                break;
            }
        }
        vector<int> ans(7, 0);
        for (int i = 0; i < 100; i++){
            for (int j = 0; j < 100; j++){
                ans[block[i][j]]++;
            }
        }
        for (int i = 1; i <= 6; i++){
            cout << ans[i];
            if (i != 6) cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3252