#include <iostream>

using namespace std;

int main(void){
	int hands[5];
	int w,l;
	
	while(cin >> hands[0] && hands[0]){
		bool exists[3] = {false, false, false};
		
		for(int i=1;i<=4;i++){
			cin >> hands[i];
		}
		for(int i=0;i<5;i++){
			exists[hands[i]-1] = true;
		}
		
		//print results
		if( ((int)exists[0] + (int)exists[1] + (int)exists[2]) % 2 == 1){
			for(int i=0; i<5;i++) cout << 3 << endl;
		}else{
			if(exists[0] == false){
				w = 2; l = 3;
			}else if(exists[1] == false){
				w = 3; l = 1;
			}else{
				w = 1; l = 2;
			}
			for(int i=0;i<5;i++){
				if(hands[i] == w){
					cout << 1 << endl;
				}else{
					cout << 2 << endl;
				}
			}
		}
	}
}