#include<iostream>

int main(){
	int p[8], c[8] = {4, 1, 4, 1, 2, 1, 2, 1};
	while(std::cin >> p[0], !std::cin.eof()){
		for(int i=1;i<8;i++){
			std::cin >> p[i];
		}

		int pos = 0, max_n = 0;
		for(int i=6;i<14;i++){
			int _n = (p[i%8]>4)?4:p[i%8];
			_n += (p[(i+2)%8]>4)?4:p[(i+2)%8];
			if(_n >= max_n){
				pos = i%8;
				max_n = _n;
			}
		}
		
		for(int i=0;i<8;i++){
			std::cout << c[(8-pos+i)%8] << " ";
		}
		std::cout << "\n";
	}
}