#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;

const int INF=1000000;
char field[101][101];
int d[101][101];
int N,M;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int MAX_V=100;
const int MAX_N=100;


int main(){
	
	int v[8];
	int p[8][8]={{4,1,4,1,2,1,2,1},{4,1,2,1,2,1,4,1},{2,1,4,1,4,1,2,1},{2,1,2,1,4,1,4,1},{1,4,1,4,1,2,1,2},{1,4,1,2,1,2,1,4},{1,2,1,4,1,4,1,2}
		,{1,2,1,2,1,4,1,4}};
	
	while(cin>>v[0]){
		REP(i,1,8)
			cin>>v[i];
		int k=0;
		long long max=1000000;
		rep(i,8){
			int	sum=0;
			rep(j,8){
				//debug(v[j]);
				//debug(p[i][j]);
				if(v[j]-p[i][j]>0)
					sum+=v[j]-p[i][j];
				//debug(sum);
		}
			if(max>=sum){
				max=sum;
				k=i;
				//debug(k);
			}
		}
		cout<<p[k][0];
		REP(i,1,8)
			cout<<" "<<p[k][i];
		cout<<endl;
	}
	
}