#include <iostream>
#include <algorithm>
#include <array>
#include <climits>

using namespace std;

int main() {
  while (true) {
    array<int,8> a = {};
    array<int,8> b = {1, 4, 1, 4, 1, 2, 1, 2};
    for_each(a.begin(), a.end(), [](auto &v) {cin >> v;});

    if (cin.fail())
      break;

    int summin = INT_MAX;
    array<int, 8> c;

    for (int i = 0; i < 8; ++i) {
      int sum = 0;
      for (int j = 0; j < 8; ++j) {
        int tmp = a[j] - b[j];
        sum += (tmp >= 0) ? tmp : 0;
      }

      bool flag = true;
      if (sum == summin) {
        for (int j = 0; j < 9; ++j) {
          if (b[j] == c[j])
            continue;
          flag = b[j] < c[j];
          break;
        }
      }

      if ((sum < summin) || (sum == summin && flag)) {
        summin = sum;
        c = b;
      }

      rotate(b.begin(), b.begin() + 1, b.end());
    }

    cout << c[0];
    for_each(c.begin()+1, c.end(), [](auto &v) { cout << " " << v; });
    cout << endl;
  }
}
