#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<int> card;
vector<string> str;

int sum = 0;


void input() {

	while (true) {
		CI n;
		if (n == 0) {
			break;
		}
		card.push_back(n);
	}

	return;
}


int main(void) {
	int goo = 0;
	int choki = 0;
	int paa = 0;
	input();

	REP(i, card.size() / 5) {
		for (int j = (i * 5); j < (i * 5) + 5; j++) {
			switch (card[j]) {
			case 1:
				goo++;
				break;
			case 2:
				choki++;
				break;
			case 3:
				paa++;
				break;
			default:
				break;
			}
		}
		if (goo > 0 && choki > 0 && paa > 0) {
			REP(j, 5)CO 3 E
		}
		else {
			if (goo > 0 && choki > 0 && paa <= 0) {
				for (int j = i * 5; j < (i * 5) + 5; j++) {
					switch (card[j]) {
					case 1:
						CO 1 E
							break;
					case 2:
						CO 2 E
							break;
					default:
						break;
					}
				}
			}
			if (goo <= 0 && choki > 0 && paa > 0) {
				for (int j = i * 5; j < (i * 5) + 5; j++) {
					switch (card[j]) {
					case 1:
						break;
					case 2:
						CO 1 E
							break;
					case 3:
						CO 2 E
							break;
					default:
						break;
					}
				}
			}
			if (goo > 0 && choki <= 0 && paa > 0) {
				for (int j = i * 5; j < (i * 5) + 5; j++) {
					switch (card[j]) {
					case 1:
						CO 2 E
						break;
					case 2:
						break;
					case 3:
						CO 1 E
						break;
					default:
						break;
					}
				}
			}
			

		}
		goo = 0;
		choki = 0;
		paa = 0;
	}


	return 0;
}