### constant

CX, CY = [20, 20]
BX, BY = [CX * 2 + 1, CY * 2 + 1]

### subroutines

def rot_x(dc0, n = 1)
  dc = dc0
  n.times.each{dc = [dc[0], 7 - dc[2], dc[1]]}
  dc
end

def rot_y(dc0, n = 1)
  dc = dc0
  n.times.each{dc = [dc[2], dc[1], 7 - dc[0]]}
  dc
end

def rot_z(dc0, n = 1)
  dc = dc0
  n.times.each{dc = [7 - dc[1], dc[0], dc[2]]}
  dc
end

### main

dices = 7.times.map{[]}
dc = [1, 2, 3]

4.times do
  dices[dc[2] - 1][dc[0] - 1] = dc
  4.times do
    dices[dc[2] - 1][dc[0] - 1] = dc
    4.times do
      dices[dc[2] - 1][dc[0] - 1] = dc
      dc = rot_z(dc)
    end
    dc = rot_y(dc)
  end
  dc = rot_x(dc)
end
#p dices; exit

loop do
  n = gets.to_i
  break if n == 0

  brd = BY.times.map{BX.times.map{[0, nil]}}

  n.times do
    ti, fi = gets.split.map(&:to_i)
    #p [[ti, fi], dices[ti - 1][fi - 1]]

    dc = dices[ti - 1][fi - 1]
    x, y = [CX, CY]

    loop do
      bh, bt = brd[y][x]
      max_s = 0
      tmp = [x, y, dc]

      if brd[y][x - 1][0] < bh && dc[0] >= 4 && max_s < dc[0]
        max_s = dc[0]
        tmp = [x - 1, y, rot_y(dc)]
      end
      if brd[y][x + 1][0] < bh && 7 - dc[0] >= 4 && max_s < 7 - dc[0]
        max_s = 7 - dc[0]
        tmp = [x + 1, y, rot_y(dc, 3)]
      end
      if brd[y - 1][x][0] < bh && dc[1] >= 4 && max_s < dc[1]
        max_s = dc[1]
        tmp = [x, y - 1, rot_x(dc, 3)]
      end
      if brd[y + 1][x][0] < bh && 7 - dc[1] >= 4 && max_s < 7 - dc[1]
        max_s = 7 - dc[1]
        tmp = [x, y + 1, rot_x(dc)]
      end

      break if max_s == 0

      x, y, dc = tmp
    end

    brd[y][x] = [brd[y][x][0] + 1, dc[2]]
  end
  #p brd[CY][CX]

  counts = 6.times.map{0}
  for y in (0...BY)
    for x in (0...BX)
      bh, bt = brd[y][x]
      if bh > 0
        counts[bt - 1] += 1
      end
    end
  end

  puts counts.join(' ')
end