#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <cstdlib>
#include <deque>
using namespace std;

int Jenny[8]={4,1,4,1,2,1,2,1};
vector <int> keys, value;

void t_sort(){
	for(int y = 0; y < keys.size()-1; y++){
		for(int x = 0; x < keys.size()-1; x++){
			if(value[x+1] <= value[x]){
				if(value[x] == value[x+1] && keys[x+1] < keys[x]){
					int t = keys[x];
					keys[x] = keys[x+1];
					keys[x+1] = t;
				}
				else{
					int t = value[x];
					value[x] = value[x+1];
					value[x+1]=t;
					int tk = keys[x];
					keys[x] = keys[x+1];
					keys[x+1] = tk;
				}
			}
		}
	}
}

string tostring(int t){
	char cc[100];
	sprintf(cc,"%d",t);
	string ret = cc;
	return ret;
}

int main(){
	int p[8];
	while(cin>>p[0]>>p[1]>>p[2]>>p[3]>>p[4]>>p[5]>>p[6]>>p[7]){
		keys.clear();
		value.clear();
		for(int i = 0; i < 8; i++){
			string tmp = "";
			int cost = 0;
			for(int x = 0; x < 8; x++){
				int j_p = (7 < x+i) ? (x+i)-8 : x+i;
				int t = p[x] - Jenny[j_p];
				tmp += tostring(Jenny[j_p]);
				cost += (0 < t ? t : 0);
			}
			keys.push_back(atoi(tmp.c_str()));
			value.push_back(cost);
		}
		t_sort();
		string res = tostring(keys[0]);
		for(int x = 0; x < res.size(); x++){
			cout << res[x];
			if(x == res.size()-1) puts("");
			else cout << " ";
		}
	}
}