#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main(){
	bool end = false;
	int gate[ 8 ];
	string capacity = "12121414", result;
	int slide, waitMin;

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

		slide = 0;
		waitMin = 0;
		result = "";

		for ( int i = 0; i < 8; ++i ){
			int wait = 0;
			string pattern;
			for ( int j = 0; j < 8; ++j ){
				pattern += capacity[ ( j + i ) % 8 ];
				int t = gate[ j ] - static_cast< int >( pattern[ j ] - '0' );
				wait += ( t > 0 ? t : 0 );
			}
			if ( result == "" || wait < waitMin ){
				waitMin = wait;
				result = pattern;
				slide = i;
			}else if ( wait == waitMin ){
				istringstream sp( pattern ), sr( result );
				int ip, ir;
				sp >> ip;
				sr >> ir;
				if ( ip < ir ){
					waitMin = wait;
					result = pattern;
					slide = i;
				}
			}
		}

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