#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

/*
template<class T> void disp_pos (const T& a, int start )
{
//	int size = sizeof(a)/sizeof(a[0]);
	int size = 8;
	int i,j;

//	cout << "size: " << size << endl;

	for (i = 0, j = start; i < size; ++i, j = (j + 1) % size ){
		cout << a[j];
		if (i != size - 1){
			cout << ' ';
		} // end if
	} // end for
	cout << endl;
}
*/
  
template<class T> string itos (const T& a, int start )
{
	int size = sizeof(a)/sizeof(a[0]);
	string res = "";
	int i,j;

//	cout << "size: " << size << endl;

	for (i = 0, j = start; i < size; ++i, j = (j + 1) % size ){
		res += a[j] + '0';
	} // end for	
	
	return res;
}

string disp_res (string str )
{
	int len = str.length();
	string res = "";
	int i;

	for (i = 0; i < len; ++i){
		res += str[i];
		if (i != len - 1){
			res += ' ';
		} // end if
	} // end for
	
	return res;	
}
	
int main()
{
//	cut here before submit 
//	freopen("testcase.fj", "r", stdin);

	const int flying_pos[] = { 4, 1, 4, 1, 2, 1, 2, 1 }; // order by clockwise

	string str = "";

	while (getline (cin, str ) ){
		vector <int> c (8, 0 );
		stringstream ss(str);
		int i,j;

		for (i = 0; i < 8; ++i){
			ss >> c[i];
		} // end for

		vector <int> not_ride (8, 0 );
		vector <map <int, string> > rank;

		for (i = 0; i < 8; ++i){
//			cout << "custamer:" << endl;
//			disp_pos (c, 0 );
//			cout << "vehicle: " << endl;
//			disp_pos (flying_pos, i % 8 );
			for (j = 0; j < 8; ++j){
				int remain = c[j] - flying_pos[(i+j) % 8];
				not_ride[i] += remain <= 0 ? 0 : remain;
			} // end for
//			cout << "sum_not_ride: " << not_ride[i] << endl;
			map<int, string> r;
			string curr_pos = itos (flying_pos, i % 8 );
			r.insert (make_pair (not_ride[i], curr_pos ) );
			rank.push_back (r );
		} // end for

		sort (rank.begin(), rank.end() );

		vector <map <int, string > >::iterator it = rank.begin();
//		for (i = 0; it != rank.end(); ++i, ++it ){
		map<int, string >::iterator itr = rank[0].begin();
		string res = disp_res ((*itr).second );
		cout << res << endl;
//			cout << (*itr).first << ':' << (*itr).second << endl;
//		} // end for

/*			
		// for debug
		cout << string (20, '-') << endl;
		for (i = 0; i < 8; ++i){
			cout << not_ride[i];
			if (i != 7 ){
				cout << ' ';
			} // end if
		} // end for
		cout << endl;
*/
	} // end loop
		
	return 0;
}