#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<29

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int usage[] = { 4, 1, 4, 1, 2, 1, 2, 1 };

int main()
{
//	cut here before submit 
//	freopen ("testcase.flying_jenny", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		stringstream ss (str );
		vector<int> p (8, 0 );
		rep (i, 8 ){
			ss >> p[i];
		} // end rep
		vector<int> c (8, 0 );
		rep (i, 8 ) c[i] = i;
		int res = INF;
		int ans = -1;
		rep (i, 8 ){
			int curr = 0;
			rep (j, 8 ){
				curr += max (p[j] - usage[c[(i+j)%8]], 0 );
			} // end rep
			if (res > curr ){
				res = curr;
				ans = i;
			} // end if
		} // end rep
		rep (i, 8 ){
			cout << usage[(ans+i)%8] << (i != 7 ? ' ' : '\n' );
		} // end rep
	} // end loop
		
	return 0;
}