#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;


enum FACE { NORTH, SOUTH, WEST, EAST, TOP, BOTTOM };

class dice {
private:
	int num[6];

	inline void roll(FACE a, FACE b, FACE c, FACE d) {
		swap(num[a], num[b]);
		swap(num[b], num[c]);
		swap(num[c], num[d]);
	}

public:
	dice() {
		num[TOP] = 1;
		num[BOTTOM] = 6;
		num[NORTH] = 3;
		num[SOUTH] = 4;
		num[EAST] = 5;
		num[WEST] = 2;
	}

	void set(int t, int f) {
		if(num[EAST] == t || num[WEST] == t) west();
		while(num[TOP] != t) north();
		while(num[NORTH] != f) ccw();
	}

	inline const int &operator[](FACE f) const { return num[f]; }

	inline void north() { roll(TOP, SOUTH, BOTTOM, NORTH); }
	inline void east()  { roll(TOP, WEST, BOTTOM, EAST); }
	inline void west()  { roll(TOP, EAST, BOTTOM, WEST); }
	inline void south() { roll(TOP, NORTH, BOTTOM, SOUTH); }

	inline void ccw() { roll(SOUTH, EAST, NORTH, WEST); }
	inline void cw()  { roll(SOUTH, WEST, NORTH, EAST); }
};

constexpr int SIZE = 30;
int top[SIZE][SIZE];
int height[SIZE][SIZE];

constexpr int dx[4] = {0, 0, -1, 1};
constexpr int dy[4] = {-1, 1, 0, 0};
void (dice::*func[4])() = {&dice::north, &dice::south, &dice::west, &dice::east};

void drop(int x, int y, dice d) {
	typedef pair<int, FACE> P;

	while(true) {
		vector<P> v{{d[NORTH], NORTH}, {d[SOUTH], SOUTH}, {d[EAST], EAST}, {d[WEST], WEST}};
		sort(begin(v), end(v), greater<P>());

		for(int i = 0; i < 3; ++i) {
			const int num = v[i].first;
			const int dir = v[i].second;

			if(num <= 3) break;

			const int nx = x + dx[dir];
			const int ny = y + dy[dir];
			if(height[y][x] > height[ny][nx]) {
				(d.*func[dir])();
				x = nx;
				y = ny;
				goto next;
			}
		}

		top[y][x] = d[TOP];
		++height[y][x];
		return;
	next:;
	}
}

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

	const int sx = SIZE / 2, sy = SIZE / 2;

	for(int n; cin >> n, n;) {
		memset(top, 0, sizeof(top));
		memset(height, 0, sizeof(height));

		for(int i = 0; i < n; ++i) {
			int t, f;
			cin >> t >> f;

			dice d;
			d.set(t, f);
			drop(sx, sy, d);
		}

		vector<int> cnt(7, 0);
		for(int i = 0; i < SIZE; ++i) {
			for(int j = 0; j < SIZE; ++j) {
				++cnt[top[i][j]];
			}
		}

		for(int i = 1; i <= 6; ++i) {
			cout << cnt[i] << (i == 6 ? "\n" : " ");
		}
	}

	return EXIT_SUCCESS;
}