#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	int p[8];
	while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]){
		int c[8];
		c[0] = 4;
		c[1] = 1;
		c[2] = 4;
		c[3] = 1;
		c[4] = 2;
		c[5] = 1;
		c[6] = 2;
		c[7] = 1;

		
		int minLeft = 100000000;
		int minV[8];
		for(int i = 0; i < 8; i++){
			int left = 0;
			for(int j = 0; j < 9; j++){
				left += max(p[j]-c[j],0);
			}
			if(minLeft > left){
				minLeft = left;
				for(int k = 0; k < 8; k++){
					minV[k] = c[k];
				}
			}
			else if(minLeft == left){
				// ツ青ョツ青板氾、ツ較ツづーツ行ツつ、
				int mul = 10000000;
				int it = 0;
				for(int k = 0; k < 8; k++){
					it += minV[k]*mul;
					mul /= 10;
				}
				int it2 = 0;
				mul = 10000000;
				for(int k = 0; k < 8; k++){
					it2 += c[k]*mul;
					mul /= 10;
				}
				if(it2 < it){
					for(int k = 0; k < 8; k++){
						minV[k] = c[k];
					}
				}
			}

			// ツバツッツフツァツづーツつクツづァツつキ
			int tmp = c[0];
			for(int i = 0; i < 7; i++){
				c[i] = c[i+1];
			}
			c[7] = tmp;
		}
		for(int i = 0; i < 8; i++){
			cout << minV[i];
			if(i == 7)
				cout << endl;
			else
				cout << " ";
		}
	}

	return 0;
}