#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int M = 8;

int m[M] = {1, 2, 1, 2, 1, 4, 1, 4};
int p[M];

int main()
{
    bool ends = 0;
    while(1)
    {
        REP(M){ cin >> p[i]; if(cin.eof()){ ends = 1; break;}}
        if(ends) break;

        int rest[M] = {};

        REP(M)//メリーゴーランドの回転
        {
            rep(j,M) rest[i] += max(0, p[j] - m[(j + i)% M]) ;
        }

        int minn = rest[0], ans = 0;
        REP(M)if(rest[i] < minn){ans = i; minn = rest[i];}

        REP(M){ cout << m[(i+ans)%8] ;  cout << " ";}
        cout << endl;
    }
    return 0;
}