#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))


struct Dice {
  int face[6];
  // +Z
  int Top() const { return face[0]; }
  int &Top() { return face[0]; }
  // -Z
  int Bottom() const { return face[1]; }
  int &Bottom() { return face[1]; }
  // +X
  int Right() const { return face[2]; }
  int &Right() { return face[2]; }
  // -X
  int Left() const { return face[3]; }
  int &Left() { return face[3]; }
  // +Y
  int Front() const { return face[4]; }
  int &Front() { return face[4]; }
  // -Y
  int Back() const { return face[5]; }
  int &Back() { return face[5]; }

  Dice Rotate(int cnt, int dir) const {
    if (cnt == 0) { return *this; }
    if (cnt < 0) { cnt = cnt % 4 + 4; }
    else { cnt %= 4; }
    Dice ret;
    if (dir == 0) {
      // +X rotate(Y axis rotate)
      ret.face[0] = face[3];
      ret.face[1] = face[2];
      ret.face[2] = face[0];
      ret.face[3] = face[1];
      ret.face[4] = face[4];
      ret.face[5] = face[5];
    } else if (dir == 1) {
      // +Y rotate(X axis rotate)
      ret.face[0] = face[4];
      ret.face[1] = face[5];
      ret.face[2] = face[2];
      ret.face[3] = face[3];
      ret.face[4] = face[1];
      ret.face[5] = face[0];
    } else if (dir == 2) {
      // Z rotate(Z axis rotate)
      ret.face[0] = face[0];
      ret.face[1] = face[1];
      ret.face[2] = face[4];
      ret.face[3] = face[5];
      ret.face[4] = face[3];
      ret.face[5] = face[2];
    } else {
      assert(false);
    }
    return ret.Rotate(cnt - 1, dir);
  }
  vector<Dice> AllRotate() const {
    vector<Dice> ret;
    Dice temp = *this;
    REP(i, 6) {
      REP(j, 4) {
        ret.push_back(temp);
        temp = temp.Rotate(1, 2);
      }
      temp = temp.Rotate(1, i & 1);
    }
    return ret;
  }
  bool operator==(const Dice &rhs) const {
    REP(i, 6) { if (face[i] != rhs.face[i]) { return false; } }
    return true;
  }
  bool operator<(const Dice &rhs) const {
    REP(i, 6) {
      if (face[i] != rhs.face[i]) { return face[i] < rhs.face[i]; }
    }
    return false;
  }
};

int n;
map<pair<int, int>, int> heights;
map<pair<int, int>, int> values;
int ans[10];
int CalcRight(int up, int face) {
  if (up == 1 && face == 2) { return 3; }
  if (up == 1 && face == 3) { return 5; }
  if (up == 1 && face == 5) { return 4; }
  if (up == 1 && face == 4) { return 2; }

  if (up == 2 && face == 3) { return 1; }
  if (up == 2 && face == 1) { return 4; }
  if (up == 2 && face == 4) { return 6; }
  if (up == 2 && face == 6) { return 3; }

  if (up == 3 && face == 5) { return 1; }
  if (up == 3 && face == 1) { return 2; }
  if (up == 3 && face == 2) { return 6; }
  if (up == 3 && face == 6) { return 5; }

  if (up == 4 && face == 1) { return 5; }
  if (up == 4 && face == 5) { return 6; }
  if (up == 4 && face == 6) { return 2; }
  if (up == 4 && face == 2) { return 1; }

  if (up == 5 && face == 1) { return 3; }
  if (up == 5 && face == 3) { return 6; }
  if (up == 5 && face == 6) { return 4; }
  if (up == 5 && face == 4) { return 1; }

  if (up == 6 && face == 3) { return 2; }
  if (up == 6 && face == 2) { return 4; }
  if (up == 6 && face == 4) { return 5; }
  if (up == 6 && face == 5) { return 3; }

  assert(false);
  return -1;
}

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

void Put(int x, int y, Dice die) {
  int mv = 3;
  int mdir = -1;
  REP(dir, 4) {
    if (die.face[dir + 2] <= mv) { continue; }
    int nx = x + dx[dir];
    int ny = y + dy[dir];
    if (heights[make_pair(nx, ny)] >= heights[make_pair(x, y)]) { continue; }
    mv = die.face[dir + 2];
    mdir = dir;
  }
  //cout << x << " " << y << " " << mdir << " " << die.Top() << endl;
  if (mdir != -1) {
    int nx = x + dx[mdir];
    int ny = y + dy[mdir];
    if (mdir == 0) { die = die.Rotate(1, 0); }
    if (mdir == 1) { die = die.Rotate(3, 0); }
    if (mdir == 2) { die = die.Rotate(3, 1); }
    if (mdir == 3) { die = die.Rotate(1, 1); }
    Put(nx, ny, die);
  } else {
    heights[make_pair(x, y)]++;
    values[make_pair(x, y)] = die.Top();
  }
}

int main() {
  while (scanf("%d", &n), n) {
    heights.clear();
    values.clear();
    MEMSET(ans, 0);
    REP(i, n) {
      //cout << i << endl;
      int up, face;
      scanf("%d %d", &up, &face);
      Dice die;
      die.Top() = up;
      die.Bottom() = 7 - up;
      die.Front() = face;
      die.Back() = 7 - face;
      die.Right() = CalcRight(up, face);
      die.Left() = 7 - CalcRight(up, face);
      Put(0, 0, die);
    }

    FORIT(it, values) {
      ans[it->second - 1]++;
    }
    REP(i, 6) {
      if (i != 0) { putchar(' '); }
      printf("%d", ans[i]);
    }
    puts("");
  }
}

Measured memory_bytes: 0