#include <iostream>
#include <vector>
#include <cstring>
int map[31][31][2];
using namespace std;
void dice(int top,int front,int x,int y)
{
  int cur = map[y][x][0];
  int u = map[y+1][x][0];
  int d = map[y-1][x][0];
  int l = map[y][x-1][0];
  int r = map[y][x+1][0];
  switch(top){
  case 1:
    switch(front){
    case 2:
      if(cur > u){
        return dice(front,7-top,x,y+1);
      }else if(cur > l){
        return dice(3,front,x-1,y);
      }
      break;
    case 3:
      if(cur > r){
        return dice(2,front,x+1,y);
      }else if(cur > u){
        return dice(front,7-top,x,y+1);
      }
      break;
    case 4:
      if(cur > l){
        return dice(2,front,x-1,y);
      }else if(cur > d){
        return dice(7-front,top,x,y-1);
      }
      break;
    case 5:
      if(cur > d){
        return dice(7-front,top,x,y-1);
      }else if(cur > r){
        return dice(3,front,x+1,y);
      }
      break;
    }
    break;
  case 2:
    switch(front){
    case 1:
      if(cur > u){
        return dice(front,7-top,x,y+1);
      }else if(cur > r){
        return dice(3,front,x+1,y);
      }
      break;
    case 3:
      if(cur > l){
        return dice(1,front,x-1,y);
      }else if(cur > u){
        return dice(front,7-top,x,y+1);
      }
      break;
    case 4:
      if(cur > r){
        return dice(1,front,x+1,y);
      }else if(cur > d){
        return dice(7-front,top,x,y-1);
      }
      break;
    case 6:
      if(cur > d){
        return dice(7-front,top,x,y-1);
      }else if(cur > l){
        return dice(3,front,x-1,y);
      }
      break;
    }
    break;
  case 3:
    switch(front){
    case 1:
      if(cur > u){
        return dice(front,7-top,x,y+1);
      }else if(cur > l){
        return dice(2,front,x-1,y);
      }
      break;
    case 2:
      if(cur > r){
        return dice(1,front,x+1,y);
      }else if(cur > u){
        return dice(front,7-top,x,y+1);
      }
      break;
    case 5:
      if(cur > l){
        return dice(1,front,x-1,y);
      }else if(cur > d){
        return dice(7-front,top,x,y-1);
      }
      break;
    case 6:
      if(cur > d){
        return dice(7-front,top,x,y-1);
      }else if(cur > r){
        return dice(2,front,x+1,y);
      }
      break;
    }
    break;
  case 4:
    switch(front){
    case 1:
      if(cur > u){
        return dice(front,7-top,x,y+1);
      }else if(cur > r){
        return dice(2,front,x+1,y);
      }
      break;
    case 2:
      if(cur > l){
        return dice(1,front,x-1,y);
      }else if(cur > u){
        return dice(front,7-top,x,y+1);
      }
      break;
    case 5:
      if(cur > r){
        return dice(1,front,x+1,y);
      }else if(cur > d){
        return dice(7-front,top,x,y-1);
      }
      break;
    case 6:
      if(cur > d){
        return dice(7-front,top,x,y-1);
      }else if(cur > l){
        return dice(2,front,x-1,y);
      }
      break;
    }
    break;
  case 5:
    switch(front){
    case 1:
      if(cur > u){
        return dice(front,7-top,x,y+1);
      }else if(cur > l){
        return dice(3,front,x-1,y);
      }
      break;
    case 3:
      if(cur > r){
        return dice(1,front,x+1,y);
      }else if(cur > u){
        return dice(front,7-top,x,y+1);
      }
      break;
    case 4:
      if(cur > l){
        return dice(1,front,x-1,y);
      }else if(cur > d){
        return dice(7-front,top,x,y-1);
      }
      break;
    case 6:
      if(cur > d){
        return dice(7-front,top,x,y-1);
      }else if(cur > r){
        return dice(3,front,x+1,y);
      }
      break;
    }
    break;
  case 6:
    switch(front){
    case 2:
      if(cur > u){
        return dice(front,7-top,x,y+1);
      }else if(cur > r){
        return dice(3,front,x+1,y);
      }
      break;
    case 3:
      if(cur > l){
        return dice(2,front,x-1,y);
      }else if(cur > u){
        return dice(front,7-top,x,y+1);
      }
      break;
    case 4:
      if(cur > r){
        return dice(2,front,x+1,y);
      }else if(cur > d){
        return dice(7-front,top,x,y-1);
      }
      break;
    case 5:
      if(cur > d){
        return dice(7-front,top,x,y-1);
      }else if(cur > l){
        return dice(3,front,x-1,y);
      }
      break;
    }
    break;
  }
  map[y][x][0]++;
  map[y][x][1] = top;
  return;
}
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n==0) break;
    memset(map,0,sizeof(map));
    for(int i=0; i<n; i++){
      int t,f;
      cin >> t >> f;
      dice(t,f,15,15);
    }
    vector<int> v(6,0);
    for(int i=0; i<31; i++){
      for(int j=0; j<31; j++){
        if(map[i][j][1] > 0){
          v[map[i][j][1]-1]++;
        }
      }
    }
    for(int i=0; i<6; i++){
      if(i!=0) cout << " ";
      cout << v[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1204