#include <iostream>
#include <set>
#include <map>
using namespace std;

int main() {
	int n[5];
	while(cin >> n[0] && n[0]){
		set<int> kind;
		kind.insert(n[0]);
		for(int i = 1; i < 5; ++i){
			cin >> n[i];
			kind.insert(n[i]);
		}
		int ans[5] = {0};
		if(kind.size() == 1){
			for(int i = 0; i < 5; ++i)
				ans[i] = 3;
		}
		else if(kind.size() == 3){
			for(int i = 0; i < 5; ++i)
				ans[i] = 3;
		}
		else{
			int win = 0;
			if(kind.find(1) != kind.end() && kind.find(2) != kind.end())
				win = 1;
			else if(kind.find(2) != kind.end() && kind.find(3) != kind.end())
				win = 2;
			else
				win = 3;
			
			for(int i = 0; i < 5; ++i){
				if(n[i] == win)
					ans[i] = 1;
				else
					ans[i] = 2;
			}
		}
		for(int i = 0; i < 5; ++i)
			cout << ans[i] << endl;
	}
	return 0;
}