#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int const d[] = {4,1,2,1,2,1,4,1,4,1,2,1,2,1,4,1,4};
  vector<int> p(8);
  while(cin>>p[0]) {
    REP(i,7)
      cin >> p[i+1];

    int mi = 1<<30;
    int ansp = 0;
    vector<int> ansv(8,9);
    REP(i,8) {
      int tmp = 0;
      REP(j,8) {
        if (p[j]>d[i+j])
          tmp += p[j]-d[i+j];
      }
      if (mi >= tmp) {

        vector<int> tmpv(8); 
        REP(j,8)
          tmpv[j] = d[i+j];
        if (mi>tmp)
          ansv = tmpv;
        else if (ansv>tmpv)
          ansv = tmpv;
        mi = tmp;
      }
    }
    REP(i,8) {
      if (i) cout << " ";
      cout << ansv[i];
    }
    cout << endl;
  }
}