// Slower C++ solution:
/*

 * Author: liuchang

 * Created Time:  2012/7/17 15:18:57

 * File Name: C.cpp

 */

#include <iostream>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <cstdlib>

#include <algorithm>

#include <vector>

using namespace std;

#define out(v) cerr << #v << ": " << (v) << endl

#define SZ(v) ((int)(v).size())

const int maxint = -1u>>1;

template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}

template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}

struct die{

    int num[6]; // top front left right back btm

die(){}

die(int top,int fr)

{

    memset(num,0,sizeof num);

    

    num[0] = top;

    num[1] = fr;

    num[5] = 7 - top;

    num[4] = 7 - fr;

     //for(int i = 0;i < 6;i ++) cout<<num[i]<<' ';cout<<endl;

    if( top == 1){

        switch( fr ){

        case 3: num[2] = 2;num[3] = 5;break;

        case 5: num[2] = 3;num[3] = 4;break;

        case 4: num[2] = 5;num[3] = 2;break;

        case 2: num[2] = 4;num[3] = 3;break;

        }

    }

    else if(top == 6){

        switch( fr ){

        case 3: num[2] = 2;num[3] = 5;break;

        case 5: num[2] = 3;num[3] = 4;break;

        case 4: num[2] = 5;num[3] = 2;break;

        case 2: num[2] = 4;num[3] = 3;break;

        }

        int tmp = num[2];num[2] = num[3];num[3] = tmp;

    }    

    else if(top == 3){

        switch(fr){

        case 6: num[2] = 2;num[3] = 5;break;

        case 5: num[2] = 6;num[3] = 1;break;

        case 1: num[2] = 5;num[3] = 2;break;

        case 2: num[2] = 1;num[3] = 6;break;

        }

    }

    else if(top == 4){

    switch(fr)

    {

        case 6: num[2] = 2;num[3] = 5;break;

        case 5: num[2] = 6;num[3] = 1;break;

        case 1: num[2] = 5;num[3] = 2;break;

        case 2: num[2] = 1;num[3] = 6;break;

    }

        int tmp = num[2];num[2] = num[3];num[3] = tmp;

    }

    else if(top == 2){

    switch(fr){

        case 1: num[2] = 3;num[3] = 4;break;

        case 4: num[2] = 1;num[3] = 6;break;

        case 6: num[2] = 4;num[3] = 3;break;

        case 3: num[2] = 6;num[3] = 1;break;

    }

    }

    else {

    switch(fr){

        case 1: num[2] = 3;num[3] = 4;break;

        case 4: num[2] = 1;num[3] = 6;break;

        case 6: num[2] = 4;num[3] = 3;break;

        case 3: num[2] = 6;num[3] = 1;break;

    }

    int tmp = num[2];num[2] = num[3];num[3] = tmp;

    }

    //for(int i = 0;i < 6;i ++) cout<<num[i]<<' ';cout<<endl;

}

        

    void rot_left()

    {

        int tmp;

        tmp = num[0];

        num[0] = num[3];

        num[3] = num[5];

        num[5] = num[2];

        num[2] = tmp;

    }

    void rot_right()

    {

        int tmp;

        tmp = num[0];

        num[0] = num[2];

        num[2] = num[5];

        num[5] = num[3];

        num[3] = tmp;

    }

    

    void rot_front()

    {

        int tmp;

        tmp = num[0];

        num[0] = num[4];

        num[4] = num[5];

        num[5] = num[1];

        num[1] = tmp;

    }

    void rot_back()

    {

        int tmp;

        tmp = num[0];

        num[0] = num[1];

        num[1] = num[5];

        num[5] = num[4];

        num[4] = tmp;

    }

    int gettop()

{

   return num[0];

} 

int get_front()

    {

        return num[1];

    }

    int get_left()

{

    return num[2];

}

int get_right(){

    return num[3];

}

int get_back(){

    return num[4];

}

void rot(int x)

{

    switch(x){

        case 0: rot_front();break;

        case 1: rot_back();break;

        case 2: rot_left();break;

        case 3: rot_right();break;

    }

}

int get(int x)

{

    switch(x){

        case 0: return get_front();break;

        case 1: return get_back();break;

        case 2: return get_left();break;

        case 3: return get_right();break;

    }

}

} dics;

int n;

int high[1000][1000],val[1000][1000];

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

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

int main() {

    while(cin>>n && n!=0)

    {

        int x,y,z,a,b;

        memset(high,0,sizeof high);

        memset(val,0,sizeof val);

        for(int i = 0;i < n;i ++)

        {

            cin>>a>>b;

            die nxt = die(a,b);

            y = x = 500;

            z = high[x][y];

            do{

            int mx = 3,dir = -1;

            for(int i = 0;i < 4;i ++)

            { 

               if( nxt.get(i) > mx &&

                   high[x+dx[i]][y+dy[i]] < z){

                   mx = nxt.get(i);

                   dir = i;

               }

            } 

            //cout<<"rot "<<dir<<endl;

            if(dir == -1){

                //cout<<nxt.gettop()<<endl;

                //cout<<"x y z "<<x<<' '<<y<<' '<<z<<endl; 

                high[x][y] ++;

                val[x][y] = nxt.gettop();

                break;

            }

            else {

                nxt.rot(dir);

                x += dx[dir];

                y += dy[dir];

                z  = high[x][y];

            }

            }while(1);

        }

        int ans[7];

        memset(ans,0,sizeof ans);

        for(int i = 0;i < 505;i ++)

            for(int j = 0;j < 505;j ++)

                ans[val[i][j]] ++;

        for(int i = 1;i <= 5;i ++)

           cout<<ans[i]<<' ';

       cout<<ans[6]<<endl;

    } 

            

            

            

        

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.41524616210838x):
/*

 * Author:heroming

 * File:heroming.cpp

 * Time:2012-7-17 13:29:51

 */

#include <iostream>

#include <cstdio>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

using namespace std;



#define SZ(v) ((int)(v).size())

const int MAXN = 30, MID = 15;

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

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

const int OPPO[] = {0, 6, 5, 4, 3, 2, 1};

const int LEFT[7][7] = {{0, 0, 0, 0, 0, 0, 0}, {0, 0, 4, 2, 5, 3, 0}, {0, 3, 0, 6, 1, 0, 4}, {0, 5, 1, 0, 0, 6, 2}, {0, 2, 6, 0, 0, 1, 5}, {0, 4, 0, 1, 6, 0, 3}, {0, 0, 3, 5, 2, 4, 0}};



int n, t, f, A[7], B[7];

int P[MAXN][MAXN][MAXN][2];

int T[MAXN][MAXN];



void fall(int x, int y, int z, int top, int front)

{

        int ff = front;

        memset(B, -1, sizeof(B));

        for (int k = 0; k < 4; ++ k)

        {

                if (ff >= 4 && ff <= 6)

                        B[ff] = k;

                ff = LEFT[top][ff];

        }

        for (int i = 6; i >= 4; -- i)

        {

                if (B[i] == -1)

                        continue;

                int k = B[i];

                int a = x + dx[k];

                int b = y + dy[k];

                if (T[a][b] < z)

                {

                        int tt;

                        if (k == 0)

                                tt = top;

                        else if (k == 2)

                                tt = OPPO[top];

                        else

                                tt = front;

                        fall(a, b, T[a][b], OPPO[i], tt);

                        return;

                }

        }



        P[x][y][z + 1][0] = top;

        P[x][y][z + 1][1] = front;

        ++ T[x][y];

}



int main()

{

        while (scanf("%d", &n) != EOF && n)

        {

                memset(P, 0, sizeof(P));

                memset(T, 0, sizeof(T));

                for (int i = 0; i < n; ++ i)

                {

                        scanf("%d%d", &t, &f);

                        fall(MID, MID, T[MID][MID], t, f);

                }

                memset(A, 0, sizeof(A));

                for (int i = 0; i < MAXN; ++ i)

                        for (int j = 0; j < MAXN; ++ j)

                                ++ A[P[i][j][T[i][j]][0]];

                printf("%d", A[1]);

                for (int i = 2; i <= 6; ++ i)

                        printf(" %d", A[i]);

                printf("\n");

        }

        return 0;

}