#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int a[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 p[8],t[8];
int cal(int n)
{
	int sum=0;
	for(int i=0;i<8;i++)
	{
		if(a[n][i]>=p[i])continue;
		sum+=p[i]-a[n][i];
	}
	return sum;
}
int main()
{
	while(scanf("%d %d %d %d %d %d %d %d",&p[0],&p[1],&p[2],&p[3],&p[4],&p[5],&p[6],&p[7])!=EOF)
	{
		int i,mi=INF;
		for(i=0;i<8;i++)
		{
			t[i]=cal(i);
			mi=min(mi,t[i]);
		}
		for(i=0;i<8;i++)
		{
			if(mi==t[i])break;
		}
		for(int j=0;j<8;j++)
		{
			if(j!=7)
			{
				cout << a[i][j] << ' ';
			}
			else
			{
				cout << a[i][j] << endl;
			}
		}
	}
	return 0;
}