#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int n = 8;
const int s[] = {4, 1, 4, 1, 2, 1, 2, 1};
int p[n];
int res;
int ptr;

inline int next(int& ptr){ return ptr = (ptr + 1) % n; }

int main()
{
  while(true){
    int sum;
    int mn = INF;
    rep(i, n) if(!(cin >> p[i])) return 0;
    rep(i, n){
      sum = 0;
      rep(j, n) sum += max(p[j] - s[(i + j) % n], 0);
      if(mn == sum){
        vi a, b;
        rep(k, n) a.pb(s[(k + res) % n]);
        rep(k, n) b.pb(s[(k + i) % n]);
        if(a > b) res = i;
      }
      else if(minup(mn, sum)) res = i;
    }
    rep(i, n) cout << s[(i + res) % n] << (i >= n-1 ? "\n" : " ");
  }

  return 0;
}