#include <iostream>
#include <algorithm>
#include <cstring>
 
using namespace std;
 
class Die {
private:
  int num[3];
 
public:
  Die(int a, int b, int c) {
    num[0] = a, num[1] = b, num[2] = c;
  }
  Die(int t, int f) {
    generate(t, f);
  }
 
  Die() {
    num[0] = num[1] = num[2] = -1;
  }
 
  void rotateN() {
    int new_die[3] = {7-num[1], num[0], num[2]};
    memcpy(num, new_die, sizeof(num));
  }
 
  void rotateE() {
    int new_die[3] = {num[2], num[1], 7-num[0]};
    memcpy(num, new_die, sizeof(num));
  }
 
  void rotateW() {
    int new_die[3] = {7-num[2], num[1], num[0]};
    memcpy(num, new_die, sizeof(num));
  }
 
  void rotateS() {
    int new_die[3] = {num[1], 7-num[0], num[2]};
    memcpy(num, new_die, sizeof(num));
  }
 
  void rotateR() {
    int new_die[3] = {num[0], 7-num[2], num[1]};
    memcpy(num, new_die, sizeof(num));
  }
 
  void generate(int t, int f) {
    num[0] = 1, num[1] = 3, num[2] = 5;
    while (true) {
      for (int i=0; i<4; i++) {
        if (num[0] == t && num[1] == f) return;
        rotateR();
      }
      rotateN();
 
      for (int i=0; i<4; i++) {
        if (num[0] == t && num[1] == f) return;
        rotateR();
      }
      rotateW();
    }
  }
 
  void print() {
    cout << num[0] << ", " << num[1] << ", " << num[2] << endl;
  }
 
  Die* operator = (Die &ohter) {
    memcpy(num, ohter.num, sizeof(num));
    return this; 
  }
 
  void clear() {
    num[0] = num[1] = num[2] = -1;
  }

  int top() { return num[0]; }
  int front() { return num[1]; }
  int left() { return 7 - num[2]; }
  int right() { return num[2]; }
  int back() { return 7 - num[1]; }
  int bottom() { return 7 - num[0]; }
};
 
Die d[210][210][100];
 
void init()
{
  for (int y=0; y<210; y++) {
    for (int x=0; x<210; x++) {
      for (int z=0; z<100; z++) {
        d[x][y][z].clear();
      }
    }
  }
}
 
int main()
{
  int N;
  while (cin >> N,  N) {
    init();
    int cnt[210][210] = {};
 
    for (int i=0; i<N; i++) {
      int T, F;
      cin >> T >> F;

      Die tmp_d(T, F);
      int sx = 110, sy = 110, sz = cnt[sx][sy];
 
      d[sx][sy][sz] = tmp_d;
      cnt[sx][sy]++;
 
      // cerr << "-------------" << endl;
      while (true) {
        // cerr << sx << " " << sy << " " << sz << endl;
        if (sz == 0) break;
 
        bool update = false;
        for (int nn=6; nn>=4; nn--) { 
          Die nd = tmp_d;
          int nx = sx, ny = sy, nz = sz;

          if (d[sx][sy][sz].front() == nn) {
            // cerr << "rotateN" << endl;
            nx = sx, ny = sy+1;
            nd.rotateN();
          } else if (d[sx][sy][sz].right() == nn) {
            // do rotateW
            // cerr << "rotateW" << endl;
            nx = sx+1, ny = sy;
            nd.rotateW();
          } else if (d[sx][sy][sz].back() == nn) {
            // do rotateS
            // cerr << "rotateS" << endl;
            nx = sx, ny = sy - 1;
            nd.rotateS();
          } else if (d[sx][sy][sz].left() == nn) {
            // do rotateE
            nx = sx - 1, ny = sy;
            nd.rotateE();
            // cerr << "rotateE" << endl;
          }
          
          nz = cnt[nx][ny];
          if ((nx!=sx || ny!=sy) && sz > nz && d[nx][ny][nz].top() == -1) {
              d[nx][ny][nz] = nd;
              cnt[nx][ny]++;

              d[sx][sy][sz].clear();
              cnt[sx][sy]--;
              sx = nx, sy = ny, sz = nz;
              tmp_d = nd;
              update = true;

              break;
          }
        }
        if (!update) break;
      }
      // cerr << "(" << sx << ", " << sy << ", " << sz << ")" << " : ";
      // d[sx][sy][sz].print();
    }
 
    int ans[6] = {};
    for (int y=0; y<210; y++) {
      for (int x=0; x<210; x++) {
        if (cnt[x][y] == 0) continue;
        ans[d[x][y][cnt[x][y] - 1].top() - 1]++;
      }
    }
 
    for (int i=0; i<6; i++) {
      if (i>0) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 54960