#include <bits/stdc++.h>
#define range(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) range(i,0,n)
using namespace std;

int a[8];
inline vector<int> cmp(vector<int> b,vector<int> c){
	int bb=0,cc=0;
	rep(i,8) bb+=max(a[i]-b[i],0);
	rep(i,8) cc+=max(a[i]-c[i],0);
	if(bb < cc) return b;
	if(cc < bb) return c;
	if(b < c) return b;
	if(c < b) return c;
	return b;
}

int main(void){
	while(1){
		rep(i,8) cin >> a[i];
		if(cin.eof()) break;
  		vector<int> s={4,1,4,1,2,1,2,1};
  		vector<int> ans={4,1,4,1,2,1,2,1};
  		rep(loop,8){
  			rotate(s.begin(),s.begin()+1,s.end());
  			ans=cmp(s,ans);
  		}
  		rep(i,8) cout << (i?" ":"") << ans[i];
  		cout << endl;
	}
	return 0;
}