#include <iostream>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

enum Spot {TOP, BOTTOM, FRONT, BACK, RIGHT, LEFT};

struct Dice {
	int spot[6];
	Dice(int top, int front) {
		spot[TOP] = top;
		spot[FRONT] = front;
		spot[BOTTOM] = 7 - top;
		spot[BACK] = 7 - front;
		if ( (top == 1 && front == 3) || (top == 3 && front == 6) 
				|| (top == 6 && front == 4) || (top == 4 && front == 1) ) {
			spot[RIGHT] = 5;
			spot[LEFT] = 2;
		} else if ( (top == 3 && front == 1) || (top == 6 && front == 3) 
				|| (top == 4 && front == 6) || (top == 1 && front == 4) ) {
			spot[RIGHT] = 2;
			spot[LEFT] = 5;
		} else if ( (top == 5 && front == 3) || (top == 3 && front == 2) 
				|| (top == 2 && front == 4) || (top == 4 && front == 5) ) {
			spot[RIGHT] = 6;
			spot[LEFT] = 1;
		} else if ( (top == 3 && front == 5) || (top == 2 && front == 3) 
				|| (top == 4 && front == 2) || (top == 5 && front == 4) ) {
			spot[RIGHT] = 1;
			spot[LEFT] = 6;
		} else if ( (top == 1 && front == 5) || (top == 5 && front == 6)
				|| (top == 6 && front == 2) || (top == 2 && front == 1) ) {
			spot[RIGHT] = 4;
			spot[LEFT] = 3;
		} else if ( (top == 5 && front == 1) || (top == 6 && front == 5)
				|| (top == 2 && front == 6) || (top == 1 && front == 2) ) {
			spot[RIGHT] = 3;
			spot[LEFT] = 4;
		} else {
			cout << "ERROR" << endl;
		}
	}
	Spot find(int n) {
		for (int i = 0; i < 6; i++) {
			if (spot[i] == n) return Spot(i);
		}
	}
	Dice roll(Spot s) {
		switch (s) {
			case FRONT:
				return Dice(spot[BACK], spot[TOP]);
			case RIGHT:
				return Dice(spot[LEFT], spot[FRONT]);
			case BACK:
				return Dice(spot[FRONT], spot[BOTTOM]);
			case LEFT:
				return Dice(spot[RIGHT], spot[FRONT]);
		}
	}
};

#define offset 100
int dx[] = {0, 0, 0, 0, 1, -1};
int dy[] = {0, 0, -1, 1, 0, 0};
struct Mountain {
	int height[200][200]; // y, x
	int field[200][200];  // y, x
	Mountain() {
		memset(height, 0, sizeof(height));
		memset(field, 0, sizeof(field));
	}
	void add(Dice dice, int x=offset, int y=offset) {
		Spot s6 = dice.find(6);
		Spot s5 = dice.find(5);
		Spot s4 = dice.find(4);
		int h = height[y][x];
		if (height[y+dy[s6]][x+dx[s6]] < h) {
			add(dice.roll(s6), x+dx[s6], y+dy[s6]);
		} else if (height[y+dy[s5]][x+dx[s5]] < h) {
			add(dice.roll(s5), x+dx[s5], y+dy[s5]);
		} else if (height[y+dy[s4]][x+dx[s4]] < h) {
			add(dice.roll(s4), x+dx[s4], y+dy[s4]);
		} else {
			height[y][x]++;
			field[y][x] = dice.spot[TOP];
		}
	}
	void statistics() {
		int cnt[6] = {};
		for (int i = 0; i < 200; i++) {
			for (int j = 0; j < 200; j++) {
				if (height[i][j] > 0) {
					cnt[field[i][j]-1]++;
				}
			}
		}
		cout << cnt[0];
		for (int i = 1; i < 6; i++) {
			cout << ' ' << cnt[i];
		}
		cout << endl;
	}
};

int main() {
	int n; 
	while (cin >> n) {
		if (n == 0) break;
		Mountain mountain;
		for (int i = 0; i < n; i++) {
			int top, front;
			cin >> top >> front;
			Dice dice(top, front);
			mountain.add(dice);
		}
//		for (int i = offset-5; i < offset+5; i++) {
//			for (int j = offset-5; j < offset+5; j++) {
//				cout << mountain.height[i][j] << ' ';
//			}
//			cout << endl;
//		}
//		cout << endl;
//		for (int i = offset-5; i < offset+5; i++) {
//			for (int j = offset-5; j < offset+5; j++) {
//				cout << mountain.field[i][j] << ' ';
//			}
//			cout << endl;
//		}

	   	mountain.statistics();
	}
	return 0;
}

Measured memory_bytes: 0