#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()

int to(int data[]){
	stringstream ss;
	rep(i,8)ss << data[i];
	return atoi( ss.str().c_str() );
}
int main(){
	int table[] = {4,1,2,1,2,1,4,1};
	int n;
	string s;
	while( getline(cin,s) &&  s != "" ){
		int M = (1<<21);
		int ret[8],data[8];
		stringstream ss(s);
		
		rep(i,8)ss >> data[i];
		
		rep(i,8){
			int sum = 0;
			rep(j,8)if(data[j]>table[j])sum += data[j]-table[j];
			if( M > sum || (M == sum && to(table) < to(ret)) ){
				M = sum;
				rep(j,8)ret[j] = table[j];
			}
			rotate(table,table+1,table+8);
		}	
		rep(i,8)cout << (i?" ":"") << ret[i];cout << endl;
	}
}
	