#include <iostream>
#include <algorithm>

using namespace std;

int player[5];

int main()
{	
	while (cin >> player[0], player[0]){
		int a[2] = {0}, j = 0;
		int check[4] = {1};

		check[player[0]] = -1;
		for (int i = 1; i < 5; i++){
			cin >> player[i];
			check[player[i]] = -1;
		}
		
		for (int i = 1; i < 4; i++){
			check[0] *= check[i];
			if (check[i] == -1){
				a[j++] = i;
			}
		}
		if (check[0] == -1){
			for (int i = 0; i < 5; i++){
				player[i] = 3;
			}
		}
		else if (check[3] == -1){
			for (int i = 0; i < 5; i++){
				if (player[i] == 3)	player[i] = 1;
				else	player[i] = 2;
			}
		}
		else {
			for (int i = 0; i < 5; i++){
				if (player[i] == min(a[0], a[1]))	player[i] = 1;
				else 	player[i] = 2;
			}
		}
		for (int i = 0; i < 5; i++){
			cout << player[i] << endl;
		}
	}
	return (0);
}