#include <array>
#include <iostream>

int main() {
	int a, b, c, d, e, f, g, h;
	static const std::array<int, 8> capacity{1, 2, 1, 2, 1, 4, 1, 4};
	static const std::array<int, 8> index{ 0, 2, 6, 4, 1, 3, 7, 5 };
	while (std::cin >> a >> b >> c >> d >> e >> f >> g >> h) {
		const std::array<int, 8> wait{a, b, c, d, e, f, g, h};
		int min = 1 << 30;
		int mini = 0;
		for (const auto &idx : index) {
			int sum = 0;
			for (auto i = 0; i < 8  && sum < min; ++i) {
				sum += (capacity[(i + idx) % 8] > wait[i]) ? 0 : (wait[i] - capacity[(i + idx) % 8]);
			}
			if (sum < min) {
				min = sum;
				mini = idx;
			}
		}
		std::cout << capacity[mini];
		for (auto i = 1; i < 8; ++i) {
			std::cout << " " << capacity[(i + mini) % 8];
		}
		std::cout << std::endl;
	}
	return 0;
}