#include <cstdio>
#include <algorithm>
using namespace std;

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

int main(void)
{
    int p[8];

    while (~scanf("%d", p)){
        int mini[8] = {max(p[0] - jenny[0], 0)};
        int sum = mini[0];
        int num = 0;

        for (int i = 1; i < 8; i++){
            scanf("%d", p + i);
            mini[i] = max(p[i] - jenny[i], 0);
            sum += mini[i];
        }
#ifdef DEBUG
        for (int i = 0; i < 8; i++) printf("%d ", p[i]);
        puts("");
#endif

        for (int i = 1; i < 8; i++){
            int tmp[8];
            int tsum = 0;
            for (int j = 0; j < 8; j++){
                tmp[j] = max(p[j] - jenny[(i + j) % 8], 0);
                tsum += tmp[j];
            }
#ifdef DEBUG
            printf("\n%d\n", i);
            for (int j = 0; j < 8; j++) printf("%d ", tmp[j]);
            printf(" %d\n", tsum);
            for (int j = 0; j < 8; j++) printf("%d ", jenny[(i + j) % 8]);
            puts("");
#endif
            if (sum > tsum){
                for (int j = 0; j < 8; j++) mini[j] = tmp[j];
                sum = tsum;
                num = i;
            }
            else if (sum == tsum){
                int v1 = 0, v2 = 0;
                for (int j = 0; j < 8; j++){
                    v1 = v1 * 10 + jenny[(num + j) % 8];
                    v2 = v2 * 10 + jenny[(i + j) % 8];
                }
                if (v1 > v2){
                    for (int j = 0; j < 8; j++) mini[j] = tmp[j];
                    num = i;
                }
            }
        }

        printf("%d", jenny[num]);
        for (int i = 1; i < 8; i++) printf(" %d", jenny[(num + i) % 8]);
        puts("");
    }

    return 0;
}