// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second

using ll = long long;
using ull = unsigned long long;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

// const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
// const int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline void chmax(T &x, U y){ x = std::max<T>(x, y); }

template<typename T, typename U>
inline void chmin(T &x, U y){ x = std::min<T>(x, y); }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(c); c.erase(std::unique(std::begin(c), std::end(c))); }

// }}}

class Dice {
public:
	Dice(){
		v.resize(6);
		iota(begin(v), end(v), 1);
	}
	Dice(const vector<int> &v): v(v){}

	int top() const { return v[TOP]; }
	int front() const { return v[FRONT]; }
	int right() const { return v[RIGHT]; }
	int left() const { return v[LEFT]; }
	int back() const { return v[BACK]; }
	int bottom() const { return v[BOTTOM]; }
	int operator [] (size_t k) const { return v[k]; }
	
	void roll_front(){ roll(TOP, FRONT, BOTTOM, BACK); }
	void roll_right(){ roll(TOP, RIGHT, BOTTOM, LEFT); }
	void roll_left(){ roll(TOP, LEFT, BOTTOM, RIGHT); }
	void roll_back(){ roll(TOP, BACK, BOTTOM, FRONT); }
	void rotate_right(){ roll(FRONT, LEFT, BACK, RIGHT); }
	void rotate_left(){ roll(FRONT, RIGHT, BACK, LEFT); }

private:
	enum {
		TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM
	};

	void roll(int a, int b, int c, int d){
		swap(v[d], v[c]);
		swap(v[c], v[b]);
		swap(v[b], v[a]);
	}

private:
	vector<int> v;
};

const int dx[] = {0, 0, 1, -1, 0, 0};
const int dy[] = {0, 1, 0, 0, -1, 0};

int main()
{
	int n;
	while (cin >> n, n){
		matrix<int, 200, 200> g = {};
		matrix<int, 200, 200> h = {};
		rep(i, n){
			int t, f;
			cin >> t >> f;
			Dice d;
			rep(j, 6){
				rep(k, 4){
					if (d.top() == t && d.front() == f){
						goto BREAK;
					}
					d.rotate_right();
				}
				if (j & 1) d.roll_left();
				else d.roll_front();
			}
		BREAK:;
			int x = 100, y = 100;
			while (true){
				int maxi = -1, dir = -1;
				loop(j, 1, 5){
					if (d[j] > 3 && d[j] > maxi && h[x + dx[j]][y + dy[j]] < h[x][y]){
						maxi = d[j];
						dir = j;
					}
				}
				if (maxi == -1) break;
				else if (dir == 1) d.roll_front();
				else if (dir == 2) d.roll_right();
				else if (dir == 3) d.roll_left();
				else d.roll_back();
				x += dx[dir];
				y += dy[dir];
			}
			h[x][y]++;
			g[x][y] = d.top();
		}
		
		array<int, 7> res = {};
		rep(i, 200) rep(j, 200){
			res[g[i][j]]++;
		}

		loop(i, 1, 7){
			cout << res[i] << "\n "[i < 6];
		}
	}
}

Measured memory_bytes: 3412