#include <iostream>
using namespace std;

int ArrayToInt(const int* arry, int ofs){
	int result;
	result = arry[ofs]*10000000
			+ arry[ofs+1]*1000000
			+ arry[ofs+2]*100000
			+ arry[ofs+3]*10000
			+ arry[ofs+4]*1000
			+ arry[ofs+5]*100
			+ arry[ofs+6]*10
			+ arry[ofs+7];
	return result;
}
 
//0082
int main(){
	const int merry[15] = {1,2,1,2,1,4,1,4,1,2,1,2,1,4,1};
	int human[8] = {0};
	int remain[8] = {0};

	while(1){
		for(int i=0; i<8; ++i){
			cin >> human[i];
			if(cin.eof())break;
		}

		int min_remain = INT_MAX;
		for(int start=0; start<8; ++start){
			for(int i=0; i<8; ++i){
				int t = human[i] - merry[start+i];
				if(t>0){
					remain[start] += t;
				}
			}
			min_remain = ((min_remain < remain[start]) ? min_remain : remain[start]);
		}

		int x;
		int prev = INT_MAX;
		for(int i=0; i<8; ++i){
			if(remain[i] == min_remain){
				int t = ArrayToInt(merry, i);
				if(prev > t){
					prev = t;
					x = i;
				}
			}
		}

		cout << merry[x+0] << " " 
			<< merry[x+1] << " "
			<< merry[x+2] << " "
			<< merry[x+3] << " "
			<< merry[x+4] << " "
			<< merry[x+5] << " "
			<< merry[x+6] << " "
			<< merry[x+7] << endl;

	}
	return 0; 
}