#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const D EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> II;

/** Problem0082 : Flying Jenny **/
int main()
{
	int p[8];
	const int num[8] = {4, 1, 4, 1, 2, 1, 2, 1};
	while (1) {
		rep(i, 8)
			cin>>p[i];
		if (cin.eof()) break;

		int ans=INF, tmp=INF, idx=0;
		rep(i, 8) {
			int tt=0;
			int nnum[8];
			rep(j, 8)
				nnum[j] = num[(i+j)%8];
			
			rep(j, 8) {
				tt+=max(0, p[j] - nnum[j]);
			}
			
			if (tmp>=tt) {
				int tans = 0;
				rep(j, 8) {
					tans*=10;
					tans+=nnum[j];
				}
				if (tmp>tt) {
					ans = tans;
					tmp=tt;
					idx=i;
				} else {
					ans = min(ans, tans);
					idx=i;
				}
			}
		}
		
		cout << num[idx];
		REP(i, 1, 8) {
			cout << " " << num[(i+idx)%8];
		}
		cout << endl;
	}
}