//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <cassert>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n)  FOR(i,0,n)

int diceLefts[6][6] = {
        {0, 4, 2, 5, 3, 0},
        {3, 0, 6, 1, 0, 4},
        {5, 1, 0, 0, 6, 2},
        {2, 6, 0, 0, 1, 5},
        {4, 0, 1, 6, 0, 3},
        {0, 3, 5, 2, 4, 0}
};

int diceRights[6][6] = {
        {0, 3, 5, 2, 4, 0},
        {4, 0, 1, 6, 0, 3},
        {2, 6, 0, 0, 1, 5},
        {5, 1, 0, 0, 6, 2},
        {3, 0, 6, 1, 0, 4},
        {0, 4, 2, 5, 3, 0}
};

enum FACE {
    TOP,
    BOTTOM,
    FRONT,
    BACK,
    LEFT,
    RIGHT
};

class Dice {
public:
    Dice() {
        id.resize(6);
        id[TOP] = 1;
        id[BOTTOM] = 6;
        id[LEFT] = 4;
        id[RIGHT] = 3;
        id[FRONT] = 2;
        id[BACK] = 5;
    }

    Dice(int top, int front) {
        id.resize(6);
        id[TOP] = top;
        id[BOTTOM] = 7 - top;
        id[FRONT] = front;
        id[BACK] = 7 - front;
        id[LEFT] = diceLefts[top - 1][front - 1];
        id[RIGHT] = diceRights[top - 1][front - 1];
    }

    Dice(int top, int front, int left) {
        id.resize(6);
        id[TOP] = top;
        id[BOTTOM] = 7 - top;
        id[FRONT] = front;
        id[BACK] = 7 - front;
        id[LEFT] = left;
        id[RIGHT] = 7 - left;
    }

    //引数はサイコロの値1-6
    //値の面のFACEを返す
    int getFace(int number) const {
        for (int i = 0; i < 6; i++) if (number == id[i]) return (FACE) i;
        assert(0);
        return -1;
    }

    //引数はサイコロの向きFACE
    //faceの方向の値を返す
    int getPip(FACE face) const {
        return id[face];
    }

    //左に回転
    void rotateLeft() {
        vector<int> n_id = id;
        n_id[TOP] = id[RIGHT];
        n_id[BOTTOM] = id[LEFT];
        n_id[LEFT] = id[TOP];
        n_id[RIGHT] = id[BOTTOM];
        id = n_id;
    }

    //右に回転
    void rotateRight() {
        vector<int> n_id = id;
        n_id[TOP] = id[LEFT];
        n_id[BOTTOM] = id[RIGHT];
        n_id[LEFT] = id[BOTTOM];
        n_id[RIGHT] = id[TOP];
        id = n_id;
    }

    //手前に回転
    void rotateFront() {
        vector<int> n_id = id;
        n_id[TOP] = id[BACK];
        n_id[BOTTOM] = id[FRONT];
        n_id[FRONT] = id[TOP];
        n_id[BACK] = id[BOTTOM];
        id = n_id;
    }

    //後方に回転
    void rotateBack() {
        vector<int> n_id = id;
        n_id[TOP] = id[FRONT];
        n_id[BOTTOM] = id[BACK];
        n_id[FRONT] = id[BOTTOM];
        n_id[BACK] = id[TOP];
        id = n_id;
    }

    //時計回りに回転()
    void rotateClockwise() {
        vector<int> n_id = id;
        n_id[FRONT] = id[RIGHT];
        n_id[BACK] = id[LEFT];
        n_id[LEFT] = id[FRONT];
        n_id[RIGHT] = id[BACK];
        id = n_id;
    }

    //反時計回りに回転()
    void rotateReClockwise() {
        vector<int> n_id = id;
        n_id[FRONT] = id[LEFT];
        n_id[BACK] = id[RIGHT];
        n_id[LEFT] = id[BACK];
        n_id[RIGHT] = id[FRONT];
        id = n_id;
    }

public:
    bool operator==(const Dice &b) const {
        const Dice &a = *this;
        return a.getPip(TOP) == b.getPip(TOP) && a.getPip(BOTTOM) == b.getPip(BOTTOM) &&
               a.getPip(FRONT) == b.getPip(FRONT) && a.getPip(BACK) == b.getPip(BACK) &&
               a.getPip(LEFT) == b.getPip(LEFT) && a.getPip(RIGHT) == b.getPip(RIGHT);
    }

    vector<Dice> allRotates() {
        vector<Dice> ret;
        for (int k = 0; k < 6; (k & 1 ? rotateRight() : rotateFront()), ++k)
            for (int i = 0; i < 4; rotateClockwise(), ++i)
                ret.push_back(*this);
        return ret;
    }

private:
    //値に数字1-6が入る
    //添字はFACEで向き
    vector<int> id;
};

int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

int main() {

    while (true) {
        int N;
        cin >> N;

        if (N == 0) break;

        VI t(N), f(N);
        REP(i, N) {
            cin >> t[i];
            cin >> f[i];
        }

        vector<vector<stack<Dice>>> map(200, vector<stack<Dice>>(200));
        //first=y second = x;
        PII start = make_pair(100, 100);

        REP(i, N) {
            PII point = start;
            Dice dice(t[i], f[i]);

            while (true) {

                bool isMoved = false;

                for (int i = 6; i >= 4; i--) {

                    int dice_eye = -1;
                    int direction = -1;

                    if (dice.getFace(i) == BACK) {
                        dice_eye = i;
                        direction = 0;
                    }
                    if (dice.getFace(i) == RIGHT) {
                        dice_eye = i;
                        direction = 1;
                    }
                    if (dice.getFace(i) == FRONT) {
                        dice_eye = i;
                        direction = 2;
                    }
                    if (dice.getFace(i) == LEFT) {
                        dice_eye = i;
                        direction = 3;
                    }

                    if (dice_eye == -1) {
                        continue;
                    }

                    PII to = make_pair(point.first + dy[direction], point.second + dx[direction]);
                    int diff = map[point.first][point.second].size() - map[to.first][to.second].size();

                    if (diff >= 1) {
                        point = to;
                        switch (direction) {
                            case 0:
                                dice.rotateBack();
                                break;
                            case 1:
                                dice.rotateRight();
                                break;
                            case 2:
                                dice.rotateFront();
                                break;
                            case 3:
                                dice.rotateLeft();
                                break;
                        }
                        isMoved = true;
                        break;
                    } else {
//                        map[point.first][point.second].push(dice);
//                        break;
                        continue;
                    }
                }

                if (!isMoved) {
                    map[point.first][point.second].push(dice);
                    break;
                }

            }

        }

        VI counts(6, 0);
        REP(i, map.size()) {
            REP(j, map[i].size()) {
                if (!map[i][j].empty()) {
                    Dice dice = map[i][j].top();
                    counts[dice.getPip(TOP) - 1]++;
                }
            }
        }

        REP(i, 6) {

            if(i==5){
                cout << counts[i];
            }else{
                cout << counts[i] << " ";
            }
        }
        cout << endl;

    }

    return 0;
}
























































Measured memory_bytes: 29540