#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

#define ITER( c ) __typeof( c ).begin()
#define REP( i, m, n ) for ( int i = m; i < n; i++ )
#define UREP( i, m, n ) for ( unsigned int i = m; i < n; i++ )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) c.begin(), c.end()
#define PB( n ) push_back( n );
#define MP( a, b ) make_pair( a, b )

int main()
{
	vector<int> viecle;
	viecle.PB( 1 );
	viecle.PB( 2 );
	viecle.PB( 1 );
	viecle.PB( 2 );
	viecle.PB( 1 );
	viecle.PB( 4 );
	viecle.PB( 1 );
	viecle.PB( 4 );

	while ( true )
	{
		string buffer;
		getline( cin, buffer );
		
		if ( buffer.length() == 0 )
		{
			break;
		}

		istringstream iss( buffer );
		vector<int> wait;

		REP( i, 0, 8 )
		{
			int in;
			iss >> in;
			wait.PB( in );
		}

		int min = INT_MAX, curr;
		vector<int> v, res;

		REP( i, 0, 8 )
		{
			curr = 0;
			v = viecle;

			REP( j, 0, i )
			{
				int tmp = v[0];
				v.erase( v.begin() );
				v.PB( tmp );
			}

			REP( j, 0, v.size() )
			{
				curr += abs( v[j] - wait[j] );
			}

			if ( curr < min )
			{
				min = curr;
				res = v;
			}
		}

		REP( i, 0, res.size() )
		{
			cout << res[i] << ( i + 1 == res.size() ? '\n' : ' ' );
		}
	}

	return 0;
}