#include <bits/stdc++.h>

using namespace std;

struct Dice {
  int t, f;
  Dice(int t, int f):t(t), f(f){}
  int get_prim()
  {
    return (t != 1 && t != 6 ? 6 : 5);
  }
  int roll_prim()
  {
    int face = get_prim();
    if(face == f) return 0;
    if(7-face == f) return 1;
    if(t%2 && f < 4 || !(t%2) && f > 3) return 2;
    if(t%2 && f > 3 || !(t%2) && f < 4) return 3;
  }
  int get_seco()
  {
    return (t != 3 && t != 4 ? 4 : 5);    
  }
  int roll_seco()
  {
    int face = get_seco();
    if(face == f) return 0;
    if(7-face == f) return 1;
    if(t%2 && f > 3 || !(t%2) && f < 4) return 2;
    if(t%2 && f < 4 || !(t%2) && f > 3) return 3;    
  }
  void roll(int d, int e)
  {
    switch(d) {
    case 0: swap(f, t); t = 7 - t; break;
    case 1: swap(f, t); f = 7 - f; break;
    default: t = 7 - e; break;
    }
  }
};

int mas[100][100];
int hei[100][100];

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

void dice_fall(Dice die, int x, int y)
{
  int d[] = {die.roll_prim(), die.roll_seco()};
  int e[] = {die.get_prim(), die.get_seco()};
  for(int i = 0; i < 2; i++) {
    int nx = x + dx[d[i]], ny = y + dy[d[i]];
    if(hei[y][x] > hei[ny][nx]) {
      die.roll(d[i], e[i]);
      dice_fall(die, nx, ny);
      return;
    }
  }
  mas[y][x] = die.t;
  hei[y][x]++;
  return;
}

int main()
{
  int n;
  while(cin >> n, n) {
    memset(mas, 0, sizeof(mas));
    memset(hei, 0, sizeof(hei));
    for(int i = 0; i < n; i++) {
      int t, f; cin >> t >> f;
      dice_fall(Dice(t, f), 50, 50);
    }
 
    int ans[6] = {0};
    for(int i = 0; i < 100; i++) {
      for(int j = 0; j < 100; j++) {
	if(mas[i][j] == 0) continue;
	ans[mas[i][j]-1]++;
      }
    }
    for(int i = 0; i < 6; i++)  cout << ans[i] << (i!=5 ? ' ' : '\n');
  }
  return 0;
}