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

int main(){
	int pos[] = {0, 1, 4, 1, 4, 1, 2, 1, 2};
	vector<int> p(9), c(pos, pos + 9);

	while(1){
		for(int i = 1; i <= 8; ++i){
			if(scanf("%d", &p[i]) == EOF){ return 0; }
		}

		vector<int> ans(9, 1000000000);
		for(int i = 0; i < 8; ++i){
			c[0] = 0;
			for(int j = 1; j <= 8; ++j){
				c[0] += max(p[j] - c[j], 0);
			}
			ans = min(ans, c);
			rotate(c.begin() + 1, c.begin() + 2, c.end());
		}

		for(int i = 1; i <= 8; ++i){
			printf("%d%c", ans[i], i == 8 ? '\n' : ' ');
		}
	}
}