//#include <bits/stdc++.h>
#include <limits>
#include <utility>
#include <bitset>
#include <functional>
#include <tuple>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <cmath>

#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
//#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

int main(){
  int n;
  while(cin>>n,n){
    int mp[200][200]={};
    int hei[200][200]={};
    int sx=100,sy=100;
    rep(i,n){
      int top,front;
      cin>>top>>front;
      int x=sx,y=sy;
      while(1){
        bool flag=false;//転がれた
        if(top==1){
          //5 4
          if(front==2){
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=2;;goto at;}
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=3;goto at;}
          }
          else if(front==3){
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=2;goto at;}
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=3;;goto at;}
          }
          else if(front==4){
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=2;goto at;}
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=3;goto at;}
          }
          else if(front==5){
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=2;goto at;}
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=3;goto at;}
          }
        }
        else if(top==2){
          //6 5
          if(front==1){
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=1;goto at;}
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=3;goto at;}
          }
          else if(front==3){
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=1;goto at;}
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=3;goto at;}
          }
          else if(front==4){
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=1;;goto at;}
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=3;goto at;}
          }
          else if(front==6){
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=1;goto at;}
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=3;goto at;}
          }
        }
        else if(top==3){
          //6 5
          if(front==1){
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=1;goto at;}
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=2;goto at;}
          }
          else if(front==2){
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=1;goto at;}
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=2;goto at;}
          }
          else if(front==5){
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=1;goto at;}
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=2;goto at;}
          }
          else if(front==6){
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=1;goto at;}
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=2;goto at;}
          }
        }
        else if(top==4){
          //6 5
          if(front==1){
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=1;goto at;}
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=2;goto at;}
          }
          else if(front==2){
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=1;goto at;}
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=2;goto at;}
          }
          else if(front==5){
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=1;goto at;}
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=2;goto at;}
          }
          else if(front==6){
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=1;goto at;}
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=2;goto at;}
          }
        }
        else if(top==5){
          //6 4
          if(front==1){
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=1;goto at;}
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=3;goto at;}
          }
          else if(front==3){
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=1;goto at;}
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=3;goto at;}
          }
          else if(front==4){
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=1;goto at;}
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=3;goto at;}
          }
          else if(front==6){
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=1;goto at;}
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=3;goto at;}
          }
        }
        else if(top==6){
          //5 4
          if(front==2){
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=2;goto at;}
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=3;goto at;}
          }
          else if(front==3){
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=2;goto at;}
            if(hei[y-1][x]<hei[y][x]){y--;flag=true;front=7-top;top=3;goto at;}
          }
          else if(front==4){
            if(hei[y][x+1]<hei[y][x]){x++;flag=true;top=2;goto at;}
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=3;goto at;}
          }
          else if(front==5){
            if(hei[y+1][x]<hei[y][x]){y++;flag=true;front=top;top=2;goto at;}
            if(hei[y][x-1]<hei[y][x]){x--;flag=true;top=3;goto at;}
          }
        }
        at:;
        if(!flag)break;//もう転がれない
      }
      mp[y][x]=top;hei[y][x]++;
    }
    vector<int> ans(6);
    // loop(i,95,110){
    //   loop(j,95,110){
    //     cout<<mp[i][j]<<' ';
    //     if(mp[i][j])ans[mp[i][j]-1]++;
    //   }
    //   cout<<endl;;
    // }
    rep(i,200)rep(j,200)if(mp[i][j])ans[mp[i][j]-1]++;
    rep(i,6){
      if(0<i)cout<<' ';
      cout<<ans[i];
    }cout<<endl;
  }
 return 0;
}



Measured memory_bytes: 3408