#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int guest[8];
	while(1){
		rep(i, 8){
			if(scanf("%d", &guest[i]) == EOF)
				return 0;
		}

		int best = INT_MAX;
		string best_str;
		string str = "14141212";
		rep(i, 8){
			int cnt = 0;
			rep(j, 8)
				cnt += max(0, guest[j]-str[j]+'0');
			if(cnt<best || (cnt==best && str<best_str)){
				best = cnt;
				best_str = str;
			}

			char tmp = str[0];
			rep(j, 7)
				str[j] = str[j+1];
			str[7] = tmp;
		}

		rep(i, 8)
			printf("%s%c", i?" ":"", best_str[i]);
		puts("");
	}

	return 0;
}