// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cstring>

#include <vector>

#include <algorithm>

using namespace std;



typedef long long int lint;

struct {

	int nDice, tmp_score, last_score;

} mp[201][201] = { };



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

int right_side[7][7] = {{ },

						{0, 0, 3, 5, 2, 4},

						{0, 4, 0, 1, 6, 0, 3},

						{0, 2, 6, 0, 0, 1, 5},

						{0, 5, 1, 0, 0, 6, 2},

						{0, 3, 0, 6, 1, 0, 4},

						{0, 0, 4, 2, 5, 3}};

int final_score[7] = { };



void roll(int top, int front, int row, int col);



int main()

{

	int n = 0;

	while(scanf("%d", &n) == 1 && n != 0)

	{

		int top = 0, front = 0;

		for(int i = 0; i < 201; i++)

			for(int j = 0; j < 201; j++)

				mp[i][j].nDice = mp[i][j].tmp_score = mp[i][j].last_score = 0;

		for(int i = 1; i < 7; i++)

			final_score[i] = 0;

		while(n-- > 0)

		{

			scanf("%d %d", &top, &front);

			mp[100][100].nDice++;

			final_score[mp[100][100].tmp_score]--;

			mp[100][100].last_score = mp[100][100].tmp_score;

			mp[100][100].tmp_score = top;

			final_score[top]++;

			roll(top, front, 100, 100);

		}

		for(int i = 1; i < 7; i++)

			printf("%d%s", final_score[i], i == 6? "\n" : " ");

	}

	return 0;

}



void roll(int top, int front, int row, int col)

{

	int dire = 0;

	for(int i = 4; i < 7; i++)

	{

		if(i != top && i != opposide[top])

		{

			if(i == front && mp[row + 1][col].nDice + 1 < mp[row][col].nDice)

					dire = dire > i ? dire : i;

			else if(i == opposide[front] && mp[row - 1][col].nDice + 1 < mp[row][col].nDice)

					dire = dire > i ? dire : i;

			else if(i == right_side[top][front] && mp[row][col + 1].nDice + 1 < mp[row][col].nDice)

					dire = dire > i ? dire : i;

			else if(i == opposide[right_side[top][front]] && mp[row][col - 1].nDice + 1 < mp[row][col].nDice)

					dire = dire > i ? dire : i;

		}

	}

	if(dire > 0)

	{

		mp[row][col].nDice--;

		final_score[mp[row][col].tmp_score]--;

		mp[row][col].tmp_score = mp[row][col].last_score;

		final_score[mp[row][col].tmp_score]++;

		if(dire == front)

		{

			mp[row + 1][col].nDice++;

			final_score[mp[row + 1][col].tmp_score]--;

			final_score[opposide[front]]++;

			mp[row + 1][col].last_score = mp[row + 1][col].tmp_score;

			mp[row + 1][col].tmp_score = opposide[front];

			roll(opposide[front], top, row + 1, col);

		}

		else if(dire == opposide[front])

		{

			mp[row - 1][col].nDice++;

			final_score[mp[row - 1][col].tmp_score]--;

			mp[row - 1][col].last_score = mp[row - 1][col].tmp_score;

			mp[row - 1][col].tmp_score = front;

			final_score[mp[row - 1][col].tmp_score]++;

			roll(front, opposide[top], row - 1, col);

		}

		else if(dire == right_side[top][front])

		{

			mp[row][col + 1].nDice++;

			final_score[mp[row][col + 1].tmp_score]--;

			mp[row][col + 1].last_score = mp[row][col + 1].tmp_score;

			mp[row][col + 1].tmp_score = opposide[right_side[top][front]];

			final_score[mp[row][col + 1].tmp_score]++;

			roll(opposide[right_side[top][front]], front, row, col + 1);

		}

		else if(dire == opposide[right_side[top][front]])

		{

			mp[row][col - 1].nDice++;

			final_score[mp[row][col - 1].tmp_score]--;

			mp[row][col - 1].last_score = mp[row][col - 1].tmp_score;

			mp[row][col - 1].tmp_score = right_side[top][front];

			final_score[mp[row][col - 1].tmp_score]++;

			roll(right_side[top][front], front, row, col - 1);

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.2223471093712337x):
#include <bits/stdc++.h>

#define int long long

// using ii = pair<int, int>;

using namespace std;



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

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

vector<int> tbl[] = {

    {},

    {4, 2, 3, 5},

    {4, 6, 3, 1},

    {1, 2, 6, 5},

    {6, 2, 1, 5},

    {4, 1, 3, 6},

    {4, 5, 3, 2},

};



void solve() {

    int n; cin >> n;

    if (n == 0) exit(0);

    vector<int> t(n), f(n);

    for (int i = 0; i < n; i++) cin >> t[i] >> f[i];



    vector<vector<int>> num(100, vector<int>(100));

    vector<vector<int>> top(100, vector<int>(100));

    for (int i = 0; i < n; i++) {

        int x = 50, y = 50;

        int ct = t[i], cf = f[i];

        while (1) {

            // cout << x << " " << y << endl;

            int face = find(tbl[ct].begin(), tbl[ct].end(), cf) - tbl[ct].begin();

            bool no = true;

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

                int tmp = find(tbl[ct].begin(), tbl[ct].end(), k) - tbl[ct].begin();

                if (tmp >= 4) continue;

                int dif = (tmp - face + 4) % 4;

                int nx = x + dx[dif], ny = y + dy[dif];

                if (num[x][y] > num[nx][ny]) {

                    x = nx, y = ny;

                    if (dif == 0) cf = ct;

                    if (dif == 2) cf = 7 - ct;

                    ct = tbl[ct][(tmp + 2) % 4];

                    no = false;

                    break;

                }

            }

            if (no) break;

        }

        num[x][y]++;

        top[x][y] = ct;

    }



    vector<int> ans(7);

    for (int i = 0; i < 100; i++) {

        for (int j = 0; j < 100; j++) {

            ans[top[i][j]]++;

        }

    }

    for (int i = 1; i < 7; i++) {

        cout << ans[i] << (i == 6 ? "" : " ");

    }

    cout << endl;

}



signed main() {

    while (1) solve();

}