#include <stdio.h>
#include <string.h>

typedef struct {
	int height;
	int num;
} FIELD;

FIELD field[ 27 ][ 27 ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };
const int roll[ 2 ][ 4 ][ 2 ] = { { { 1, 0 }, { 2, 1 }, { 0, 3 }, { 3, 2 } }, { { 1, 2 }, { 0, 1 }, { 2, 3 }, { 3, 0 } } };
const int l[ 12 ] = { 3, 1, 4, 2, 2, 5, 0, 3, 4, 0, 5, 1 };

void move( int, int, int, int );

int main( void ) {
	int n, x, y, t, f, count[ 7 ];

	while ( scanf( "%d", &n ), n ) {
		memset( count, 0, sizeof( int ) * 7 );
		memset( field, 0, sizeof( FIELD ) * 729 );

		while ( n-- ) {
			scanf( "%d %d", &t, &f );

			move( 13, 13, t - 1, f - 1 );
		}

		for ( y = 0; y < 27; y++ )
			for ( x = 0; x < 27; x++ )
				count[ field[ x ][ y ].num ]++;

		for ( x = 1; x < 6; x++ )
			printf( "%d ", count[ x ] );
		printf( "%d\n", count[ 6 ] );
	}

	return 0;
}

void move( int x, int y, int t, int f ) {
	int i, ff;

	ff = 0;
	for ( i = 0; ; i++ ) {
		if ( i == t || i == 5 - t )
			continue;
		if ( i == f )
			break;

		ff++;
	}

	for ( i = 0; i < 2; i++ ) {
		int d = roll[ t % 2 ][ ff ][ i ], nx = x + dx[ d ], ny = y + dy[ d ];

		if ( field[ x ][ y ].height > field[ nx ][ ny ].height )
			switch ( d ) {
				case 0:
					move( nx, ny, 5 - l[ t < 3 ? t * 4 + ff : 23 - t * 4 - ff ], f );
					return;
				case 1:
					move( nx, ny, f, 5 - t );
					return;
				case 2:
					move( nx, ny, l[ t < 3 ? t * 4 + ff : 23 - t * 4 - ff ], f );
					return;
				case 3:
					move( nx, ny, 5 - f, t );
					return;
			}
	}

	field[ x ][ y ].height++;
	field[ x ][ y ].num = t + 1;

	return;
}