#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
template <class T>
class dice {
public:
  dice() {
    id[TOP] = 0; id[FRONT] = 1; id[LEFT] = 2;
    id[RIGHT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
  }
  T& operator[] (FACE f) { return var[id[f]]; }
  const T& operator[] (FACE f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    T tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

typedef dice<int> di;
typedef vector<di > vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;

const int OFFSET=100;

int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
FACE faces[]={BACK,RIGHT,FRONT,LEFT};
void roll(vvvd &field,int y,int x){
	FACE dir=TOP;
	int dir_i=0;
	REP(i,4){
		int yy=y+dy[i];
		int xx=x+dx[i];
		di d=field[y][x].back();
		if(field[yy][xx].size()<field[y][x].size()-1&&d[faces[i]]>=4){
			if(dir==TOP||d[faces[i]]>d[dir]){
				dir=faces[i];
				dir_i=i;
			}
		}
	}
	if(dir!=TOP){
		di d=field[y][x].back();
		field[y][x].pop_back();
		switch(dir){
		case BACK:
			REP(i,3)d.roll_x();
			break;
		case RIGHT:
			d.roll_y();
			break;
		case FRONT:
			d.roll_x();
			break;
		case LEFT:
			REP(i,3)d.roll_y();
			break;
		}
		field[y+dy[dir_i]][x+dx[dir_i]].push_back(d);
		roll(field,y+dy[dir_i],x+dx[dir_i]);
	}
}

int main(){
	int n;
	while(cin>>n,n){
		vvvd field(OFFSET*2,vvd(OFFSET*2));
		di idea;
		idea[TOP]=1;
		idea[LEFT]=2;
		idea[FRONT]=3;
		idea[BACK]=4;
		idea[RIGHT]=5;
		idea[BOTTOM]=6;
		REP(i,n){
			int t,f;
			cin>>t>>f;
			vector<di> rolls=idea.all_rolls();
			di die_to_fall;
			REP(i,rolls.size()){
				if(rolls[i][TOP]==t&&rolls[i][FRONT]==f){
					die_to_fall=rolls[i];
					break;
				}
			}
			field[OFFSET+0][OFFSET+0].push_back(die_to_fall);
			roll(field,OFFSET+0,OFFSET+0);
		}
		vi ans(6);
		REP(i,field.size()){
			REP(j,field[0].size()){
				if(field[i][j].size()){
					di &d=field[i][j].back();
					int num=d[TOP];
					ans[num-1]++;
				}
			}
		}
		REP(i,6){
			cout<<(i==0?"":" ")<<ans[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 2112