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

const int N = 8;
const int cap[N] = {4,1,4,1,2,1,2,1};
int num[N];

int main() {
  while(1) {
    for(int i = 0; i < N; ++i) {
      if(cin >> num[i]) ; else return 0;
    }
    int res = (1<<30);
    vector<int> v;
    for(int j = 0; j < N; ++j) {
      int sum = 0;
      for(int i = 0; i < N; ++i) {
        sum += max(0, num[i] - cap[(i+j)%N]);
      }
      if(sum <= res) {
        vector<int> t;
        for(int i = 0; i < N; ++i) t.push_back(cap[(i+j)%N]);
        if(sum == res) {
          v = min(v, t);
        } else {
          res = sum;
          v = t;
        }
      }
    }
    for(int i = 0; i < N; ++i) {
      if(i) cout << " ";
      cout << v[i];
    }
    cout << endl;
  }
  return 0;
}