#include <iostream>
using namespace std;

int main()
{
	int hand[ 5 ], ans[ 5 ];
	while( cin >> hand[ 0 ] && hand[ 0 ] ){
		int flag = 0;
		for( int i = 1; i < 5; ++i ){
			cin >> hand[ i ];
			flag |= ( 1 << ( hand[ i ] - 1 ) );
		}
		if( flag == 1 || flag == 2 || flag == 4 || flag == 7 ){
			for( int i = 0; i < 5; ++i ){
				ans[ i ] = 3;
			}
		}else{
			int win = 0;
			if( flag == 3 ) win = 1;
			if( flag == 6 ) win = 2;
			if( flag == 5 ) win = 3;
			for( int i = 0; i < 5; ++i ){
				if( hand[ i ] == win ) ans[ i ] = 1;
				else ans[ i ] = 2;
			}
		}
		for( int i = 0; i < 5; ++i ){
			cout << ans[ i ] << endl;
		}
	}
	return 0;
}