#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int c[8] = {1,2,1,2,1,4,1,4};
int main(void){
  int p[8];
  while(cin>>p[0]){
    FOR(i,1,8) cin>>p[i];
    int sum = -1;
    int ans = 0;
    int pnum;
    REP(i,8){
      int tmp = 0;
      REP(k,8){
        tmp += min(c[(k+i)%8],p[k]);
      }
      if(tmp>sum){
        ans = i;
        sum = tmp;
        pnum = 0;
        REP(k,8){
          pnum += pow(10,7-k) * c[(k+i)%8];
        }
      }else if(tmp==sum){
        int ptmp=0;
        REP(k,8){
          ptmp += pow(10,7-k) * c[(k+i)%8];
        }
        if(ptmp<pnum){
          pnum = ptmp;
          ans = i;
          sum = tmp;
        }
      }
    }
    bool f=false;
    REP(i,8){
      if(f){
        cout<<" ";
      }else{
        f = true;
      }
      cout<<c[(i+ans)%8];
    }
    cout<<endl;
  }
  return 0;
}