#include<iostream>

int main(){
	int p[8], c[8] = {012121414, 014121214,
										012141412, 014141212,
										021214141, 041212141,
										021414121, 041412121};
	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=0;i<8;i++){
			int _n = 0;
			for(int j=0;j<8;j++){
				_n += (p[j]>(c[i]>>3*j&07))?(c[i]>>3*j&07):p[j];
			}
			if(_n >= max_n){
				pos = i;
				max_n = _n;
			}
		}

		for(int i=0;i<8;i++){
			std::cout << (c[pos]>>3*i&07);
			if(i < 7)std::cout << " ";
		}
		std::cout << "\n";
	}
}