#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

struct Dice
{
	int top, bottom;
	VI sides;

	Dice( int t, int f ) : top( 1 ), bottom( 6 ), sides{ 3, 5, 4, 2 }
	{
		if ( bottom == t )
		{
			back();
			back();
		}
		else if ( top != t )
		{
			while ( sides[0] != t )
			{
				rotate( sides.begin(), sides.begin() + 1, sides.end() );
			}
			back();
		}
		while ( sides[0] != f )
		{
			rotate( sides.begin(), sides.begin() + 1, sides.end() );
		}
		return;
	}

	void front()
	{
		kuru( 2, 0 );
		return;
	}

	void back()
	{
		kuru( 0, 2 );
		return;
	}

	void right()
	{
		kuru( 3, 1 );
		return;
	}

	void left()
	{
		kuru( 1, 3 );
		return;
	}

	void kuru( int s1, int s2 )
	{
		swap( top, sides[ s1 ] );
		swap( sides[ s1 ], bottom );
		swap( bottom, sides[ s2 ] );
		return;
	}

	VI dirs()
	{
		VI res;
		for ( int tar = 6; 4 <= tar; --tar )
		{
			auto pos = find( ALL( sides ), tar ) - sides.begin();
			if ( pos == 4 )
			{
				continue;
			}
			res.PB( pos );
		}
		return res;
	}
};

const int DIRECTION[][2] = {
	1, 0,
	0, 1,
	-1, 0,
	0, -1
};

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		VVI heights( 200, VI( 200, 0 ) );
		VVI tops( 200, VI( 200, 0 ) );

		REP( in, 0, n )
		{
			int t, f;
			cin >> t >> f;

			int y = 100, x = 100;
			Dice dice( t, f );

			while ( true )
			{
				bool moved = false;
				VI dirs( dice.dirs() );
				
				REP( i, 0, dirs.size() )
				{
					if ( heights[y][x] <= heights[ y + DIRECTION[ dirs[i] ][0] ][ x + DIRECTION[ dirs[i] ][1] ] )
					{
						continue;
					}

					y += DIRECTION[ dirs[i] ][0];
					x += DIRECTION[ dirs[i] ][1];
					switch ( dirs[i] )
					{
						case 0:
							dice.front();
							break;
						case 1:
							dice.right();
							break;
						case 2:
							dice.back();
							break;
						case 3:
							dice.left();
							break;
					}

					moved = true;
					break;
				}

				if ( !moved )
				{
					break;
				}
			}

			heights[y][x]++;
			tops[y][x] = dice.top;
		}

		VI res( 7 );
		REP( i, 0, tops.size() )
		{
			REP( j, 0, tops[0].size() )
			{
				res[ tops[i][j] ] ++;
			}
		}

		REP( i, 1, 7 )
		{
			if ( i - 1 )
			{
				cout << ' ';
			}
			cout << res[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1524