#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const ll dx[4] = {0, 1, 0, -1};
const ll dy[4] = {-1, 0, 1, 0};
const ll tbl[6][4] = {
    {5, 4, 2, 3},
    {3, 1, 4, 6},
    {6, 5, 1, 2},
    {1, 5, 6, 2},
    {1, 3, 6, 4},
    {3, 2, 4, 5},
};
class Dice {
    ll t, f;
public:
    Dice(ll top, ll front) : t(top), f(front) {}
    ll top() { return t; }
    ll front() { return f; }
    ll right() {
        rep(i, 4) {
            if (tbl[t-1][i] == f) {
                return tbl[t-1][(i+1)%4];
            }
        }
        return -1;
    }
    ll bottom() { return 7-top(); }
    ll left() { return 7-right(); }
    ll rear() { return 7-front(); }
};

P f(ll top, ll front, ll dir) {
    Dice d(top, front);
    switch (dir) {
    case 0: return P(d.front(), d.bottom());
    case 1: return P(d.left(), d.front());
    case 2: return P(d.rear(), d.top());
    case 3: return P(d.right(), d.front());
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    while (cin >> n, n) {
        map<P, ll> h;
        map<P, ll> val;
        rep(i, n) {
            ll top, front; cin >> top >> front;
            ll x = 0, y = 0;
            while (1) {
                ll dir = -1, m = linf;
                rep(d, 4) {
                    ll nx = x + dx[d];
                    ll ny = y + dy[d];
                    if (h[P(nx, ny)] >= h[P(x, y)]) continue;
                    if (f(top, front, d).first < min(m, 4LL)) {
                        dir = d;
                        m = f(top, front, dir).first;
                    }
                }
                if (dir < 0) break;
                P p = f(top, front, dir);
                tie(top, front) = p;
                x += dx[dir];
                y += dy[dir];
                // cout << top << " " << front << endl;
            }
            // cout << "!" << x << " " << y << endl;
            h[P(x, y)]++;
            val[P(x, y)] = top;
        }
        vector<ll> ans(6, 0);
        each(p, val) {
            ans[p.second-1]++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3112