#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>

using namespace std;

bool solve(){ 
	int p[8];
	for(int i= 0 ;i < 8; i++) if(!(cin>>p[i])) return false;
	static int s[8][8] = {
		{1,2,1,2,1,4,1,4},
		{1,2,1,4,1,4,1,2},
		{1,4,1,2,1,2,1,4},
		{1,4,1,4,1,2,1,2},
		{2,1,2,1,4,1,4,1},
		{2,1,4,1,4,1,2,1},
		{4,1,2,1,2,1,4,1},
		{4,1,4,1,2,1,2,1},
	};

	int min_i = -1;
	int mn = INT_MAX;
	for (int i = 0; i < 8; i++){
		int a = 0;
		for (int j = 0; j < 8; j++)	a += max(0,p[j] - s[i][j]);
		if(a < mn){
			min_i = i;
			mn = a;
		}
	}
	for(int i = 0; i < 8; i++) printf("%d%c",s[min_i][i],(i == 7) ? '\n' : ' ');
	return true;
}

int main(){

	while(solve());
    return 0;
}