#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <array>

using namespace std;

int main ()
{
	array<int , 8>A,P,Q,ANS;
	A[0] = 4;
	A[1] = 1;
	A[2] = 4;
	A[3] = 1;
	A[4] = 2;
	A[5] = 1;
	A[6] = 2;
	A[7] = 1;
	while( cin >> P[0] )
	{
		for( size_t i = 1; i < 8; i++ )
		{
			cin >> P[i];
		}
		int memo = INT_MAX;
		for( size_t i = 0; i < 8; i++ )
		{
			Q = P;
			int memo2=0,memo3=0;
			for( size_t j = 0; j < 8; j++ )
			{
				Q[j] -= min(A[j],Q[j]);
				memo2 += Q[j];
			}
			if( memo >= memo2 )
			{
				memo = memo2;
				if( memo > memo2 )
				{
					ANS = A;
				} else
				{
					for( size_t j = 0; j < 8; j++ )
					{
						if( ANS[j]>A[j] )
						{
							ANS = A;
							break;
						} else
						{
							break;
						}
					}
				}
			}
			rotate ( A.begin () , A.begin () + 1 , A.end () );
		}
		for( size_t i = 0; i < 7; i++ )
		{
			cout << ANS[i] << " ";
		}
		cout << ANS[7] << endl;
	}
}