#include <iostream>
#include <climits>
using namespace std;

int main(){
	bool end = false;
	int gate[ 8 ];
	int capacity[ 8 ] = { 1, 2, 1, 2, 1, 4, 1, 4 };
	int waitMin, pattern;

	while ( !end ){
		for ( int i = 0; i < 8; ++i ){
			end = !( cin >> gate[ i ] );
			if ( end ) break;
		} if ( end ) continue;

		waitMin = INT_MAX;

		for ( int i = 0; i < 8; ++i ){
			int wait = 0;
			for ( int j = 0; j < 8; ++j ){
				int t = gate[ j ] - capacity[ ( j + i ) % 8 ];
				wait += ( t > 0 ? t : 0 );
			}
			if ( wait < waitMin ){
				waitMin = wait;
				pattern = i;
			}
		}

		bool first = true;
		for ( int i = 0; i < 8; ++i ){
			if ( first ){
				first = false;
				cout << capacity[ ( i + pattern ) % 8 ];
			}else{
				cout << " " << capacity[ ( i + pattern ) % 8 ];
			}
		}
		cout << endl;
	}
	return 0;
}