#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
#include <complex>
using namespace std;
 
const double EPS = 1e-9;
const double PI = 3.14159265359;
 
typedef complex<double> P;

const int k[8] = {0, 2, 6, 4, 1, 3, 7, 5};
const int c[8] = {1, 2, 1, 2, 1, 4, 1, 4};

int rest(int *p, int i){
	int v = 0;
	for(int j = 0; j < 8; j++){
		int r = p[j] - c[(j+k[i])%8];
		if(r > 0){
			v+=r;
		}
	}

	return v;
}

int main(){
 
	int p[8];
	while(cin >> p[0]){
		for(int i = 1; i < 8; i++){
			cin >> p[i];
		}
		int m = rest(p, 0);
		int im = 0;
		for(int i = 1; i < 8; i++){
			if(m > rest(p, i)){
				m = rest(p, i);
				im = i;
			}
		}

		bool f = true;

		for(int i = 0; i < 8; i++){
			if(!f){
				cout << ' ';
			}
			f = true;
			cout << c[(i+k[im])%8];
		}
		cout << endl;

	}

    return 0;
}