#include<algorithm>
#include<iostream>
#include<vector>

int p[8];
int c[8] = { 4, 1, 4, 1, 2, 1, 2, 1 };

int main()
{
	while( std::cin >> p[0] )
	{
		for( int i = 1; i != 8; ++i )
			std::cin >> p[i];

		std::vector<int> ans( 8, 0 );
		int mi = 1 << 30;
		for( int r = 0; r != 8; ++r )
		{
			int rest = 0;
			std::vector<int> mem( 8, 0 );

			for( int i = 0; i != 8; ++i )
			{
				mem[i] = c[( i + r ) % 8];
				rest += std::max( 0, p[i] - mem[i] );
			}

			if( mi > rest || ( mi == rest && ans > mem ) )
			{
				mi = rest;
				std::copy( mem.begin(), mem.end(), ans.begin() );
			}
		}

		for( int i = 0; i != 8; ++i )
			std::cout << ans[i] << ( i == 7 ? '\n' : ' ' );
	}

	return 0;
}