#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

vector<vector<pair<int,int>>>data;

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

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

void datapop(int t, int f, int high, int x, int y)
{
	if (high == 0)
	{
		data[x][y].second = t;
		data[x][y].first = 1;
		return;
	}
	int memo=0,memo2=0;
	for (size_t i = 0; i < 4; i++)
	{
		if (data[x + dx[i]][y + dy[i]].first < high)
		{
			if (dice[t-1][f-1][i] == 4)
			{
				if (memo < 4)
				{
					memo = 4;
					memo2 = i;
				}
			} else if (dice[t-1][f-1][i] == 5)
			{
				if (memo < 5)
				{
					memo = 5;
					memo2 = i;
				}
			} else if (dice[t-1][f-1][i] == 6)
			{
				if (memo < 6)
				{
					memo = 6;
					memo2 = i;
				}
			}
		}
	}
	if (!memo)
	{
		data[x][y].first++;
		data[x][y].second = t;
		return;
	}
	switch (memo2)
	{
		case 0:f = t; break;
		case 1:break;
		case 2:f = 7 - t; break;
		case 3:break;
		default:
			break;
	}
	datapop(7 - memo, f, data[x + dx[memo2]][y + dy[memo2]].first, x + dx[memo2], y + dy[memo2]);
	return;
}

int main()
{
	int n;
	int t, f;
	while (cin >> n, n)
	{
		data.clear();
		data.resize(30);
		for (size_t i = 0; i < 30; i++)
		{
			data[i].resize(30);
		}
		for (size_t i = 0; i < n; i++)
		{
			cin >> t >> f;
			datapop(t, f, data[15][15].first, 15, 15);
		}
		vector<int>ans;
		ans.resize(6);
		for (auto x : data)
		{
			for (auto y : x)
			{
				if (y.second)
				{
					ans[y.second - 1]++;
				}
			}
		}
		for (size_t i = 0; i < 5; i++)
		{
			cout << ans[i] << " ";
		}
		cout << ans[5] << endl;
	}
}

Measured memory_bytes: 1208