#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

struct dice{
    int top, front;
    int right_table[7][7];
    dice(int t, int f):top(t), front(f){
        right_table[3][2] = 1;
        right_table[2][4] = 1;
        right_table[4][5] = 1;
        right_table[5][3] = 1;
        right_table[1][3] = 2;
        right_table[3][6] = 2;
        right_table[6][4] = 2;
        right_table[4][1] = 2;
        right_table[2][1] = 3;
        right_table[1][5] = 3;
        right_table[5][6] = 3;
        right_table[6][2] = 3;
        right_table[5][1] = 4;
        right_table[1][2] = 4;
        right_table[2][6] = 4;
        right_table[6][5] = 4;
        right_table[3][1] = 5;
        right_table[1][4] = 5;
        right_table[4][6] = 5;
        right_table[6][3] = 5;
        right_table[5][4] = 6;
        right_table[4][2] = 6;
        right_table[2][3] = 6;
        right_table[3][5] = 6;
    };
    dice(){};
    
    int getBack(int num){
        return 7 - num;
    }
    
    int getRight(int t, int f){
        return right_table[f][t];
    }
    
    void roll(int mode){
        int nt, nf;
        
        if(mode == 1){
            nt = getBack(front);
            nf = top;       
        }       

        if(mode == 2){
            nt = getBack(getRight(top, front));
            nf = front;
        }
        
        if(mode == 3){
            nt = front;
            nf = getBack(top);
        }

        if(mode == 4){
            nt = getRight(top, front);
            nf = front;
        }
        top = nt;
        front = nf;
    }
};


signed main(){

    while(1){
        int n; cin >> n;
        if(n == 0) break;
        vector<vector<vector<dice> > > a(100, vector<vector<dice> > (100, vector<dice> (1, dice(0, 0))));
        
        for(int i = 0; i < n; i++){
            int t, f; cin >> t >> f;
            dice Dice = dice(t, f);
            int x = 50; int y = 50;
            while(1){
                int h = a[x][y].size();
                bool flag = false;

                for(int num = 6; num >= 4; num--){
                    if(Dice.front == num && a[x + 1][y].size() < h){
                        flag = true;
                        Dice.roll(1);
                        x = x + 1;
                        h = a[x][y].size();
                    }else if(Dice.getRight(Dice.top, Dice.front) == num && a[x][y + 1].size() < h){
                        flag = true;
                        Dice.roll(2);
                        y = y + 1;
                        h = a[x][y].size();
                    }else if(Dice.getBack(Dice.front) == num && a[x - 1][y].size() < h){
                        flag = true;
                        Dice.roll(3);
                        x = x - 1;
                        h = a[x][y].size();
                    }else if(Dice.getBack(Dice.getRight(Dice.top, Dice.front)) == num && a[x][y - 1].size() < h){
                        flag = true;
                        Dice.roll(4);
                        y = y - 1;
                        h = a[x][y].size();
                    }

                    if(flag) break;
                }
                
                if(flag == false){
                    a[x][y].push_back(Dice);
                    break;
                }
            }
        }
        
        //cout << "believe yourself!" << endl;
        vector<int> ans(7, 0);
        for(int x = 45; x < 55; x++){
            for(int y = 45; y < 55; y++){
                dice D = a[x][y][a[x][y].size() - 1];
                ans[D.top]++;
                //cout << D.top << " ";
            }
            //cout << endl;
        }
        
        for(int i = 1; i <= 6; i++){
            if(i == 6) cout << ans[i] << endl;
            else cout << ans[i] << " ";
        }

    }
    return 0;
}




Measured memory_bytes: 7268