// compile in C++11. use -std=c++11.
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// this require C++11
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<(int)n;i++)
#define debug(x) #x << "=" << (x)

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& val){
    os << "[ ";
    for(typename vector<T>::const_iterator it=val.begin();
        it != val.end();++it){
        os << *it << " ";
    }
    os << "]";
    return os;
}

// template<typename T,typename IT>
// struct Indexer{
//     struct iterator{
//         typedef IT inner_iterator;
//         typedef typename iterator_traits<inner_iterator>::reference inner_reference;
//         struct reference : pair<size_t,inner_reference>{
//             reference(size_t s,inner_reference i) :
//                 pair<size_t,inner_reference>(s,i) {}
//             const size_t& index = (*this).first;
//             const inner_reference& value = (*this).second;
//         };

//         iterator(inner_iterator i) : pos(0),it(i) {}
//         reference operator*() const {
//             return reference(pos,*it);
//         }
//         iterator& operator++(){
//             ++pos;++it;
//             return *this;
//         }
//         iterator operator++(int){
//             iterator tmp(*this);
//             ++(*this);
//             return tmp;
//         }
//         bool operator==(const iterator& rhs) const{
//             return it == rhs.it;
//         }
//         bool operator!=(const iterator& rhs) const{
//             return !(*this == rhs);
//         }
//     private:
//         size_t pos;
//         inner_iterator it;
//     };

//     Indexer(T& t): container(t) {};
//     iterator begin() const{
//         return iterator(container.begin());
//     }
//     iterator end() const{
//         return iterator(container.end());
//     }

// private:
//     T& container;
// };

// template<typename T>
// Indexer<T,typename T::iterator> enumerate(T& t){
//     return Indexer<T,typename T::iterator>(t);
// }
// // value will be readonly.
// template<typename T>
// Indexer<T,typename T::const_iterator> const_enumerate(T& t){
//     return Indexer<T,typename T::const_iterator>(t);
// }

struct Dice{
    int top,front,right,bottom,back,left;
    Dice(int a_top,int a_front,int a_right) :
        top(a_top),front(a_front),right(a_right),
        bottom(7-a_top),back(7-a_front),left(7-a_right)
    {}
    Dice(const Dice& d) :
        top(d.top),front(d.front),right(d.right),
        bottom(d.bottom),back(d.back),left(d.left)
    {}
    Dice rotate_front(){
        return Dice(back,top,right);
    }
    Dice rotate_back(){
        return Dice(front,bottom,right);
    }
    Dice rotate_left(){
        return Dice(right,front,bottom);
    }
    Dice rotate_right(){
        return Dice(left,front,top);
    }
    Dice &operator=(const Dice& d){
        top = d.top;
        front = d.front;
        bottom = d.bottom;
        back = d.back;
        right = d.right;
        left = d.left;
        return (*this);
    }
    ~Dice(){
    }
};

void solve(int n){
    vector<vector<int>> height(200+1,vector<int>(200+1));
    vector<vector<int>> top(200+1,vector<int>(200+1));
    // first row and col is dummy data.
    const vector<vector<int>> right = {
        {0,1,2,3,4,5,6},
        {1,0,3,5,2,4,0},
        {2,4,0,1,6,0,3},
        {3,2,6,0,1,1,5},
        {4,5,1,0,0,6,2},
        {5,3,0,6,1,0,4},
        {6,0,4,2,5,3,0},
    };
    // front,left,back,right
    const vector<int> dx = {0, 1, 0,-1};
    const vector<int> dy = {-1,0, 1, 0};
    repeat(i,n){
        int t,f,r;
        cin >> t >> f;
        r = right[t][f];
        int x=100,y=100;
        Dice dice(t,f,r);
        while(true){
            int dir = -1;
            int s = 0;
            repeat(d,4){
                int nx = dx[d]+x;
                int ny = dy[d]+y;
                if(height[ny][nx] < height[y][x]){
                    if(d == 0 and dice.front >= max(4,s)){
                        dir = d;s = dice.front;
                    }else if(d == 1 and dice.left >= max(4,s)){
                        dir = d;s = dice.left;
                    }else if(d == 2 and dice.back >= max(4,s)){
                        dir = d;s = dice.back;
                    }else if(d == 3 and dice.right >= max(4,s)){
                        dir = d;s = dice.right;
                    }
                }
            }

            if(dir != -1){
                int nx = dx[dir]+x;
                int ny = dy[dir]+y;
                if(dir == 0){
                    dice = dice.rotate_front();
                    x = nx;y = ny;
                }else if(dir == 1){
                    dice = dice.rotate_left();
                    x = nx;y = ny;
                }else if(dir == 2){
                    dice = dice.rotate_back();
                    x = nx;y = ny;
                }else if(dir == 3){
                    dice = dice.rotate_right();
                    x = nx;y = ny;
                }
            }else{
                break;
            }
        }
        height[y][x]++;
        top[y][x] = dice.top;
    }
    vector<int> ret(6);
    for(const auto& v : top){
        for(const auto a : v){
            if(a == 0) continue;
            ret[a-1]++;
        }
    }

    for(size_t i=0;i<ret.size();i++){
        cout << ret[i] << ((i!=ret.size()-1)?" ":"");
    }
    cout << endl;
}


int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 1524