#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	int u[] = { 1, 2, 1, 2, 1, 4, 1, 4 };
	int p[8];
	while (scanf("%d %d %d %d %d %d %d %d"
		, p, p+1, p+2, p+3, p+4, p+5, p+6, p+7) != EOF)
	{
		int firstUma;
		int maxRide = 0;
		for (int w = 0; w < 2; ++w)
		{
			for (int i = 0; i < 4; ++i)
			{
				int uma = (i*2 + w)%8;
				int canRide = 0;
				for (int j = 0; j < 8; ++j)
					canRide += min(p[j], u[(uma+j)%8]);
				if (canRide > maxRide)
				{
					maxRide = canRide;
					firstUma = uma;
				}
			}
		}
		for (int i = firstUma; ; i = (i+1)%8)
		{
			printf("%d", u[i]);
			if ((i+1)%8 != firstUma)
				printf(" ");
			else
			{
				printf("\n");
				break;
			}
		}
	}

	return 0;
}