#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] >>c[1]>>c[2]>>c[3]>>c[4]>>c[5]>>c[6]>>c[7]){
		if(cin.eof()) break;
		
		int mnk=1<<22, svi;
		rep(i,8){
			int sum=0;
			rep(j,8) sum += max(0, c[j] - nn[j+i]);
			if(sum < mnk){ svi=i; mnk = sum; }
		}
		rep(z,8) cout << (z? " ": "")  << nn[z+svi];
		cout << endl;
	}
	return 0;
	
}