#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

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

int bo[100][100][2];

int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < 100; i++) {
            for (int j = 0; j < 100; j++) {
                fill(bo[i][j], bo[i][j] + 2, 0);
            }
        }
        for (int i = 0; i < n; i++) {
            int t, f;
            cin >> t >> f;
            int nowx = 50;
            int nowy = 50;
            while (1) {
                int dir[3] = {-1, -1, -1};
                int fro = -1;
                for (int i = 0; i < 4; i++) {
                    if (di[t - 1][i] == f) {
                        fro = i;
                    }
                }
                for (int i = 0; i < 4; i++) {
                    for (int j = 0; j < 3; j++) {
                        if (di[t - 1][i] == 4 + j) {
                            dir[j] = (i + 4 - fro) % 4;
                        }
                    }
                }
                int move = -1;
                int num = -1;
                for (int i = 2; i >= 0; i--) {
                    if (dir[i] != -1) {
                        int xx = nowx + dx[dir[i]];
                        int yy = nowy + dy[dir[i]];
                        if (bo[nowx][nowy][0] > bo[xx][yy][0]) {
                            move = dir[i];
                            num = 4 + i;
                            nowx = xx;
                            nowy = yy;
                            break;
                        }
                    }
                }
                if (move == -1) {
                    break;
                } else {
                    if (move == 0) {
                        f = t;
                    } else if (move == 2) {
                        f = 7 - t;
                    }
                    t = 7 - num;
                }
            }
            bo[nowx][nowy][0]++;
            bo[nowx][nowy][1] = t;
            //cout << nowx << " " << nowy << " " << t << " " << f << endl;
        }
        ll ans[6] = {0, 0, 0, 0, 0, 0};
        for (int i = 0; i < 100; i++) {
            for (int j = 0; j < 100; j++) {
                if (bo[i][j][1] != 0) {
                    ans[bo[i][j][1] - 1]++;
                }
            }
        }   
        for (int i = 0; i < 6; i++) {
            cout << ans[i];
            if (i != 5) {
                cout << " ";
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3168