#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int a[5];
	while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4]) {
		int b[4] = {};
		for (int i = 0; i < 5; i++) {
			if (a[i] == 1)b[1] = 1;
			else if (a[i] == 2)b[2] = 1;
			else if (a[i] == 3)b[3] = 1;
		}

		int f = b[1] + b[2] + b[3];
		if (f == 2)
			if (!b[1])
				for (int i = 0; i < 5; i++)
					a[i] = (a[i] == 2) ? 1 : 2;
			else if (!b[2])
				for (int i = 0; i < 5; i++)
					a[i] = (a[i] == 3) ? 1 : 2;
			else
				for (int i = 0; i < 5; i++)
					a[i] = (a[i] == 1) ? 1 : 2;
		else
			for (int i = 0; i < 5; i++)
				a[i] = 3;

		for (int i = 0; i < 5; i++)
			cout << a[i] << endl;
	}
	return 0;
}