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

int main(void){
	int n[] = {4,1,4,1,2,1,2,1};

	while(1){
		int c[8];
		for(int i=0;i<8;i++) if(!(cin>>c[i])) return 0;

		string minS = "";
		int min = INT_MAX;

		for(int i=0;i<8;i++){
			int sum = 0;
			string s = "";

			for(int j=0;j<8;j++){
				s += (char)(n[(i+j)%8] + '0');
				int rem = c[j] - n[(i+j)%8];
				if(rem > 0) sum += rem;
			}

			if(min >= sum){
				if((min > sum) || (min == sum && s.compare(minS) < 0)){
					minS = s;
				}
				min = sum;
			}
		}

		for(int i=0;i<7;i++){
			cout<<minS.at(i)<<" ";
		}
		cout<<minS.at(7)<<endl;
	}
}