#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const int TOP = 0;
const int BOTTOM = 1;
const int LEFT = 2;
const int BACK = 3;
const int RIGHT = 4;
const int FRONT = 5;
class Saikoro {
public:
    int x, y;
    int V[6]; 
    bool nullType;
    Saikoro( int a, int b ) {
        V[TOP] = a;
        V[BOTTOM] = 7 - a;
        V[FRONT] = b;
        V[BACK] = 7 - b;
        const int T[6][4] = {
            { 2, 3, 5, 4 },
            { 1, 4, 6, 3 },
            { 6, 5, 1, 2 },
            { 1, 5, 6, 2 },
            { 3, 6, 4, 1 },
            { 3, 2, 4, 5 }
        };
        for ( int i = 0; i < 4; ++ i ) {
            if ( T[a-1][i] == b ) {
                int left = i - 1;
                if ( left < 0 ) left = 3;
                V[LEFT] = T[a-1][left];
                break;
            }
        }
        V[RIGHT] = 7 - V[LEFT];
        nullType = false;
    }
    int getV( int dir ) {
        return V[2+dir];
    }
    int getTop() {
        return V[0];
    }
    void rollLeft() {
        int NV[6];
        NV[FRONT] = V[FRONT];
        NV[BACK] = V[BACK];
        NV[LEFT] = V[TOP];
        NV[TOP] = V[RIGHT];
        NV[RIGHT] = V[BOTTOM];
        NV[BOTTOM] = V[LEFT];
        for ( int i = 0; i < 6; ++ i ) V[i] = NV[i];
    }
    void rollRight() {
        int NV[6];
        NV[FRONT] = V[FRONT];
        NV[BACK] = V[BACK];
        NV[LEFT] = V[BOTTOM];
        NV[BOTTOM] = V[RIGHT];
        NV[RIGHT] = V[TOP];
        NV[TOP] = V[LEFT];
        for ( int i = 0; i < 6; ++ i ) V[i] = NV[i];
    }
    void rollFront() {
        int NV[6];
        NV[LEFT] = V[LEFT];
        NV[RIGHT] = V[RIGHT];
        NV[FRONT] = V[TOP];
        NV[TOP] = V[BACK];
        NV[BACK] = V[BOTTOM];
        NV[BOTTOM] = V[FRONT];
        for ( int i = 0; i < 6; ++ i ) V[i] = NV[i];
    }
    void rollBack() {
        int NV[6];
        NV[LEFT] = V[LEFT];
        NV[RIGHT] = V[RIGHT];
        NV[FRONT] = V[BOTTOM];
        NV[BOTTOM] = V[BACK];
        NV[BACK] = V[TOP];
        NV[TOP] = V[FRONT];
        for ( int i = 0; i < 6; ++ i ) V[i] = NV[i];
    }
    void roll( int dir ) {
        if ( dir == 0 ) rollLeft();
        if ( dir == 1 ) rollBack();
        if ( dir == 2 ) rollRight();
        if ( dir == 3 ) rollFront();
    }
    Saikoro() {
        nullType = true;
    }
};

ostream& operator << ( ostream& os, Saikoro s ) {
    const string T[6] = { "TOP", "BOTTOM", "LEFT", "BACK", "RIGHT", "FRONT" };
    os << "{";
    for ( int i = 0; i < 6; ++ i ) {
        os << T[i] << ":" << s.V[i];
        if ( i + 1 < 6 ) os << ", ";
    }
    os << "}";
    return os;
}

typedef vector <Saikoro> Saikoros;
typedef vector <Saikoros> Saikoro2D;
typedef vector <Saikoro2D> Saikoro3D;
const int MAP_SIZE = 70;
const int HEIGHT = 104;
const int dr[4] = { 0, -1, 0, 1 };
const int dc[4] = { -1, 0, 1, 0 };
int n; 
Saikoros S;
int R[6];
Saikoro3D U; 
VVI D;

bool isValidSaikoro( Saikoro& s ) {
    return ! s.nullType;
}

Saikoro GetTopSaikoro( int r, int c ) {
    int depth = D[r][c] - 1;
    return U[r][c][depth];
}

void PutSaikoro( Saikoro3D& V, Saikoro s, int r, int c ) {
    int& depth = D[r][c];
    V[r][c][depth++] = s;
}

void RemoveTop( Saikoro3D& V, int r, int c ) {
    int& depth = D[r][c];
    V[r][c][depth-1].nullType = true;
    depth --;
}

bool is456( int a ) {
    return a == 4 || a == 5 || a == 6;
}

void korogasu( int r, int c ) {
    Saikoro top = GetTopSaikoro( r, c );

    int maxk = -1;
    int maxv = 0;
    for ( int k = 0; k < 4; ++ k ) {
        int nr = r + dr[k];
        int nc = c + dc[k];
        if ( D[r][c] - 1 <= D[nr][nc] ) continue;
        int v = top.getV(k);
        if ( ! is456(v) ) continue;
        if ( v > maxv ) {
            maxk = k;
            maxv = v;
        }
    }
    if ( maxk == -1 ) {
        return;
    }
             
    RemoveTop( U, r, c );
    top.roll(maxk);
    int nr = r + dr[maxk];
    int nc = c + dc[maxk];
    PutSaikoro( U, top, nr, nc );
    korogasu( nr, nc );
}

void solve() {
    D = VVI( MAP_SIZE, VI( MAP_SIZE, 1 ) );
    U = Saikoro3D( MAP_SIZE, Saikoro2D( MAP_SIZE, Saikoros( HEIGHT ) ) );
    int sr = MAP_SIZE/2, sc = MAP_SIZE/2;
    
    for ( Saikoros::iterator it_i = S.begin(); it_i != S.end(); ++ it_i ) {
        PutSaikoro( U, *it_i, sr, sc );
        korogasu( sr, sc );
    }

    
    for ( int i = 0; i < 6; ++ i ) R[i] = 0;
    for ( int i = 0; i < MAP_SIZE; ++ i ) {
        for ( int j = 0; j < MAP_SIZE; ++ j ) {
            Saikoro top = GetTopSaikoro( i, j );
            if ( top.nullType ) continue;
            int t = top.getTop();
            R[t-1] ++;
        }
    }
}

void output() {
    for ( int i = 0; i < 6; ++ i ) {
        cout << R[i];
        if ( i + 1 < 6 ) cout << " ";
    }
    cout << endl;
}

int main() {
    while ( cin >> n && n ) {
        S = Saikoros(n);
        for ( int i = 0; i < n; ++ i ) {
            int t, f;
            cin >> t >> f;
            S[i] = Saikoro( t, f );
        }
        solve();
        output();
    }
    return 0;
}

Measured memory_bytes: 36000