#include <iostream>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define INF 2147483647

int main()
{
    int w[8],c[8]={1,2,1,2,1,4,1,4},dict[8]={0,2,6,4,1,3,7,5};
    while(1)
    {
	int r[8]={0},m=INF;
	rep(i,8)if (!(cin >> w[i]))return 0;
	rep(i,8)
	{
	    rep(j,8)
	    {
		r[i]+=max(0,w[j]-c[j]);
	    }
	    m=min(m,r[i]);
	    rep(j,7)swap(c[j],c[j-1]);
	}
	rep(i,8)
	{
	    if (r[dict[i]] == m)
	    {
		rep(j,8)
		{
		    cout << c[(dict[i]+j)%8];
		    if (j!=8)cout << " ";
		}
		cout << endl;
		break;
	    }
	}
    }
    return 0;
}