#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	while(true){
		int cur = 0 ,d[5];
		rep(i,5){
			if(cin >> d[i]) d[i]-- ,  cur |= (1<<d[i]);
			else return 0;
		}
		if(__builtin_popcount(cur) == 2){
			rep(i,5)
				cout << 2 - !!count(d,d+5,(d[i]+1)%3) << endl;
		}else{
			rep(i,5)cout << 3 << endl;
		}
	}
}