// AOJ 0205
#include<iostream>
#include<set>

int main()
{
	int a[5];
	while( std::cin >> *a, *a )
	{
		std::set<int> s;
		s.insert( *a );
		for( int i = 1; i != 5; ++i )
		{
			std::cin >> a[i];
			s.insert( a[i] );
		}

		if( s.size() == 3 )
			for( int i = 0; i != 5; ++i )
				std::cout << 3 << std::endl;
		else
		{
			int win = *s.begin() == 1 ? *( ++s.begin() ) == 2 ? 1 : 3 : 2;
			for( int i = 0; i != 5; ++i )
				std::cout << ( a[i] == win ? 1 : 2 ) << std::endl;
		}
	}

	return 0;
}