#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>

//AOJ0082
#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int nn[]={4,1,4,1,2,1,2,1,4,1,4,1,2,1,2,1,4};
int c[8];

	while( cin >> c[0]){
		if(cin.eof()) break;
		rep(i,7) cin >> c[i+1];
		
		int mnk=99999, svi=-1;
		rep(i,8){
			int sum=0;
			rep(j,8) sum += max(0, c[j] - nn[j+i]);
			if(sum < mnk) svi=i; 
			mnk = min(mnk, sum);
		}
		rep(z,8) cout << nn[z+svi] << (z==7? "\n": " ");
	}
	return 0;
	
}