// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

// Dice
enum DICE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT, END };
enum ROLL { NORTH_R, SOUTH_R, EAST_R, WEST_R, LEFT_R, RIGHT_R, END_R };
	
const int right_by_tf[6][6] = {
	{ -1, 3, 5, 2, 4, -1 },
	{ 4, -1, 1, 6, -1, 3 },
	{ 2, 6, -1, -1, 1, 5 },
	{ 5, 1, -1, -1, 6, 2 },
	{ 3, -1, 6, 1, -1, 4 },
	{ -1, 4, 2, 5, 3, -1 }
};

const enum DICE rolls[6][4] = {
	{ TOP, FRONT, BOTTOM, BACK },
	{ BOTTOM, FRONT, TOP, BACK },
	{ TOP, LEFT, BOTTOM, RIGHT },
	{ TOP, RIGHT, BOTTOM, LEFT },
	{ RIGHT, BACK, LEFT, FRONT },
	{ LEFT, BACK, RIGHT, FRONT }
};

struct Dice {
private:
	int dice[6];
	
public:
	Dice() {
		dice[TOP] = 1; dice[BOTTOM] = 6;
		dice[FRONT] = 2; dice[BACK] = 5;
		dice[RIGHT] = 3; dice[LEFT] = 4;
	}
	
	Dice(int _t, int _f) {
		dice[TOP] = _t; dice[BOTTOM] = 7 - _t;
		dice[FRONT] = _f; dice[BACK] = 7 - _f;
		dice[RIGHT] = right_by_tf[_t - 1][_f - 1]; dice[LEFT] = 7 - dice[RIGHT];
	}
	
	void roll_to(enum ROLL _r) {
		int _tmp = dice[ rolls[_r][0] ];
		for_(i,0,3) dice[ rolls[_r][i] ] = dice[ rolls[_r][i + 1] ];
		dice[ rolls[_r][3] ] = _tmp;
	}
	
	int at(enum DICE _d) {
		return dice[_d];
	}
};

int n;
int cx = 50, cy = 50;
int height[100][100];
int number[100][100];

					   // FRONT, BACK, LEFT, RIGHT
const int dx[6] = { 0, 0, 0, 0, -1, 1 };
const int dy[6] = { 0, 0, 1, -1, 0, 0 };

bool can_fall(Dice& dice, int x, int y, enum DICE _d) {
	int dat = dice.at(_d);
	
	if (dat != 4 && dat != 5 && dat != 6) return false;
	
	int nx = x + dx[_d], ny = y + dy[_d];
	if (height[y][x] > height[ny][nx]) return true;
	
	return false;
}

void do_roll(Dice& dice, enum DICE _d) {
	if (_d == FRONT) dice.roll_to(SOUTH_R);
	if (_d == BACK) dice.roll_to(NORTH_R);
	if (_d == LEFT) dice.roll_to(WEST_R);
	if (_d == RIGHT) dice.roll_to(EAST_R);
}

void solve() {
	minit(height, 0);
	minit(number, 0);
	
	for_(i,0,n) {
		int t, f;
		scanf("%d %d", &t, &f);
		Dice dice(t, f);
		
		int x = cx, y = cy;
		
		while (1) {
			int ati = 0;
			enum DICE di = TOP;
			
			for (int dd = FRONT; dd < END; ++dd) {
				enum DICE d = (enum DICE)dd;
				if (can_fall(dice, x, y, d)) {
					if (ati < dice.at(d)) {
						ati = dice.at(d);
						di = d;
					}
				}
			}
			
			if (di == TOP) break;
			
			x += dx[di], y += dy[di];
			do_roll(dice, di);
		}
		
		++height[y][x];
		number[y][x] = dice.at(TOP);
	}
	
	int count[7] = { 0 };
	for_(y,0,100) for_(x,0,100) {
		++count[number[y][x]];
	}
	
	for_(i,1,7) {
		if (i < 6) printf("%d ", count[i]);
		else printf("%d\n", count[i]);
	}
}

int main() {
	while (scanf("%d", &n), n) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1272