#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 i = 0; i < 8; ++i)
		{
			int canRide = 0;
			for (int j = 0; j < 8; ++j)
				canRide += min(p[j], u[(i+j)%8]);
			if (canRide > maxRide)
			{
				maxRide = canRide;
				firstUma = i;
			}
			else if (canRide == maxRide)
			{
				int a, b;
				a = b = 0;
				for (int k = 0; k < 8; ++k)
				{
					a = a*10 + u[(firstUma+k)%8];
					b = b*10 + u[(i+k)%8];
				}
				if (a > b)
					firstUma = i;
			}
		}
		for (int i = 0; ; ++i)
		{
			printf("%d", u[(firstUma+i)%8]);
			if (i < 7)
				printf(" ");
			else
			{
				printf("\n");
				break;
			}
		}
	}

	return 0;
}