// 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 };

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 }
};

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 north_roll() {
		int _t = dice[TOP];
		dice[TOP] = dice[FRONT];
		dice[FRONT] = dice[BOTTOM];
		dice[BOTTOM] = dice[BACK];
		dice[BACK] = _t;
	}
	
	void south_roll() {
		int _b = dice[BOTTOM];
		dice[BOTTOM] = dice[FRONT];
		dice[FRONT] = dice[TOP];
		dice[TOP] = dice[BACK];
		dice[BACK] = _b;
	}
	
	void east_roll() {
		int _t = dice[TOP];
		dice[TOP] = dice[LEFT];
		dice[LEFT] = dice[BOTTOM];
		dice[BOTTOM] = dice[RIGHT];
		dice[RIGHT] = _t;
	}
	
	void west_roll() {
		int _t = dice[TOP];
		dice[TOP] = dice[RIGHT];
		dice[RIGHT] = dice[BOTTOM];
		dice[BOTTOM] = dice[LEFT];
		dice[LEFT] = _t;
	}
	
	// pivot is top
	void right_roll() {
		int _r = dice[RIGHT];
		dice[RIGHT] = dice[BACK];
		dice[BACK] = dice[LEFT];
		dice[LEFT] = dice[FRONT];
		dice[FRONT] = _r;
	}
	
	void left_roll() {
		int _l = dice[LEFT];
		dice[LEFT] = dice[BACK];
		dice[BACK] = dice[RIGHT];
		dice[RIGHT] = dice[FRONT];
		dice[FRONT] = _l;
	}
	
	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.south_roll();
	if (_d == BACK) dice.north_roll();
	if (_d == LEFT) dice.west_roll();
	if (_d == RIGHT) dice.east_roll();
}

void solve() {
	minit(height, 0);
	minit(number, 0);
	
	for_(i,0,n) {
		int t, f; cin >> t >> f;
		Dice dice(t, f);
		
		int x = cx, y = cy;
		
		while (1) {
			int ati = 0;
			enum DICE di = TOP;
			
			if (can_fall(dice, x, y, FRONT)) {
				if (ati < dice.at(FRONT)) {
					ati = dice.at(FRONT);
					di = FRONT;
				}
			}
			
			if (can_fall(dice, x, y, BACK)) {
				if (ati < dice.at(BACK)) {
					ati = dice.at(BACK);
					di = BACK;
				}
			}
			
			if (can_fall(dice, x, y, LEFT)) {
				if (ati < dice.at(LEFT)) {
					ati = dice.at(LEFT);
					di = LEFT;
				}
			}
			
			if (can_fall(dice, x, y, RIGHT)) {
				if (ati < dice.at(RIGHT)) {
					ati = dice.at(RIGHT);
					di = RIGHT;
				}
			}
			
			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) cout << count[i] << " ";
		else cout << count[i] << endl;
	}
}

int main() {
	while (cin >> n, n) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1244