#include <iostream>
#define rep(n) for(int i=0;i<(n);i++)
using namespace std;

int main(void){
	int a[5];
	while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]){
		int b[4];
		b[1]=0;
		b[2]=0;
		b[3]=0;
		rep(5)b[a[i]]++;
		if(b[1]>0&&b[2]>0&&b[3]>0){
			rep(5) cout<<3<<endl;
			continue;
		}
		if(b[1]&&b[2]){
			rep(5){
				if(a[i]==1)cout<<"1"<<endl;
				else cout<<"2"<<endl;
			}
		}else if(b[2]&&b[3]){
			rep(5){
				if(a[i]==2)cout<<"1"<<endl;
				else cout<<"2"<<endl;
			}
		}else if(b[3]&&b[1]){
			rep(5){
				if(a[i]==3)cout<<"1"<<endl;
				else cout<<"2"<<endl;
			}
		}
	}
	return 0;
}