#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = (1e-10);
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<vector<int>> diceType;
vector<vector<int>> height(300, vector<int>(300));
vector<vector<int>> state(300, vector<int>(300));

void init(void) {
    diceType.push_back({1, 3, 5, 4, 2, 6});
    diceType.push_back({1, 5, 4, 2, 3, 6});
    diceType.push_back({1, 4, 2, 3, 5, 6});
    diceType.push_back({1, 2, 3, 5, 4, 6});
    diceType.push_back({2, 1, 4, 6, 3, 5});
    diceType.push_back({2, 4, 6, 3, 1, 5});
    diceType.push_back({2, 6, 3, 1, 4, 5});
    diceType.push_back({2, 3, 1, 4, 6, 5});
    diceType.push_back({3, 1, 2, 6, 5, 4});
    diceType.push_back({3, 2, 6, 5, 1, 4});
    diceType.push_back({3, 6, 5, 1, 2, 4});
    diceType.push_back({3, 5, 1, 2, 6, 4});
    diceType.push_back({4, 1, 5, 6, 2, 3});
    diceType.push_back({4, 5, 6, 2, 1, 3});
    diceType.push_back({4, 6, 2, 1, 5, 3});
    diceType.push_back({4, 2, 1, 5, 6, 3});
    diceType.push_back({5, 1, 3, 6, 4, 2});
    diceType.push_back({5, 3, 6, 4, 1, 2});
    diceType.push_back({5, 6, 4, 1, 3, 2});
    diceType.push_back({5, 4, 1, 3, 6, 2});
    diceType.push_back({6, 2, 4, 5, 3, 1});
    diceType.push_back({6, 4, 5, 3, 2, 1});
    diceType.push_back({6, 5, 3, 2, 4, 1});
    diceType.push_back({6, 3, 2, 4, 5, 1});
}

int diceCheck(int top, int front) {
    for (int i = 0; i < diceType.size(); i++) {
        if (diceType[i][0] == top && diceType[i][1] == front) {
            return i;
        }
    }
    return -1;
}

int nextDice(int dice, int direction) {
    vector<int> crt = diceType[dice];
    int nextD;

    if (direction == 0) {
        nextD = diceCheck(7-crt[1], crt[0]);
    }
    if (direction == 1) {
        nextD = diceCheck(7-crt[2], crt[1]);
    }
    if (direction == 2) {
        nextD = diceCheck(7-crt[3], 7-crt[0]);
    }
    if (direction == 3) {
        nextD = diceCheck(7-crt[4], crt[1]);
    }
    return nextD;
}

int fall(int x, int y, int dice) {
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, -1, 0, 1};

    int ma = -1;
    int maxi = -1;
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (height[x][y] > height[nx][ny]) {
            if (diceType[dice][1+i] >= 4 && ma < diceType[dice][1+i]) {
                ma = diceType[dice][1+i];
                maxi = i;
            }
        }
    }
    if (ma == -1) {
        height[x][y]++;
        state[x][y] = diceType[dice][0];
        return 0;
    } else {
        fall(x+dx[maxi], y+dy[maxi], nextDice(dice, maxi));
    }
    return 0;
}

vector<int> solve(int N) {
    vector<int> ret(7);

    state = vector<vector<int>> (400, vector<int>(400));
    height = vector<vector<int>> (400, vector<int>(400));

    //center = {150, 150} 

    for (int i = 0; i < N; i++) {
        int t, f; cin >> t >> f;
        int dice = diceCheck(t, f);
        fall(200, 200, dice);
    }
    for (int i = 0; i < 300; i++) {
        for (int j = 0; j < 300; j++) {
            ret[state[i][j]]++;
        }
    }
    return ret;
}

int main(void) {
    int N;
    vector<vector<int>> ans;

    init();
    while (1) {
        cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }
    for (auto &v : ans) {
        for (int i = 1; i < v.size(); i++) {
            if (v.size() - 1 == i) cout << v[i] << endl;
            else cout << v[i] << " ";
        }
    }
}




Measured memory_bytes: 4740