#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int h[10];
	while (cin >> h[1], h[1]) {
		cin >> h[2] >> h[3] >> h[4] >> h[5];
		int g = 0, c = 0, p = 0;
		for (int i = 1; i <= 5; i++) {
			if (h[i] == 1)g = 1;
			else if (h[i] == 2)c = 1;
			else if (h[i] == 3)p = 1;
		}
		if ((g + c + p) % 2 != 0)for (int i = 0; i < 5; i++)cout << "3\n";
		else {
			int w;
			if (g == 0)w = 2;
			else if (c == 0)w = 3;
			else if (p == 0)w = 1;
			for (int i = 1; i <= 5; i++)if (h[i] == w)cout << 1 << endl; else cout << 2 << endl;
		}
	}return 0;
}
