#include<iostream>
using namespace std;

int main(){
	int hand[5],num[3],result[5],lose;
  while(cin>>hand[0]>>hand[1]>>hand[2]>>hand[3]>>hand[4]){
		for(int i=0;i<3;i++){
			num[i] = 0;
			result[i] = 0;
		}
		for(int i=0;i<5;i++){
			num[hand[i]-1]++;
		}
		if(num[0]*num[1]*num[2] == 0 
			 && (num[0]+1)*(num[1]+1)*(num[2]+1) != 6){
			for(lose = 0;num[lose] != 0;lose++);
			lose%=3;
			for(int i=0;i<5;i++){
				result[i] = (hand[i] == lose) ? 2 : 1;
			}
		}
		else{
			for(int i=0;i<5;i++)
				result[i] = 3;
		}
		for(int i=0;i<5;i++)
			cout<<result[i]<<endl;
	}
  return 0;
}