#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;

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

typedef pair<int, int> pp;
typedef pair<pp, int> ppp;

int main()
{
    bool ends = 0;
    while(cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4]>> p[5]>> p[6]>> p[7])
    {

        int rest[M] = {}, num[M] = {};
        vector<ppp> ans;

        REP(M)
        {
            rep(j,M){ rest[i] += max(0, p[j] - m[(j + i)% M]) ; num[i] = num[i] * 10 + m[(j+i) % M];}
            ans.push_back(ppp(pp(rest[i], num[i]), i));
        }
        sort(all(ans));
        
        REP(M){ cout << m[(i+ans[0].second) % 8] ; if(i==M-1)break; cout << " ";}
        cout << endl;
    }
    return 0;
}