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

const int uma[8] = {4, 1, 4, 1, 2, 1, 2, 1};
const int INF = 1e9;

int main() {
  vector<int> p(8);
  while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
    int m;
    string ans;
    for (int i = 0; i < 8; ++i) {
      int s = 0;
      string c;
      for (int j = 0; j < 8; ++j) {
        c += '0' + uma[(i + j) % 8];
        s += max(0, p[j] - uma[(i + j) % 8]);
      }
      if (i == 0) {
        ans = c;
        m = s;
      } else if (s <= m) {
        ans = ( (s == m && stoi(ans) < stoi(c)) ? ans : c );
        m = min(m, s);
      }
    }
    for (int i = 0; i < 8; ++i) cout << ( (i) ? " " : "" ) << ans[i];
    cout << endl;
  }
  return 0;
}

