#include<iostream>
using namespace std;

void rotate( int* a )
{
    int x = a[7];
    for( int i = 6; i >= 0; i-- )
        a[i+1] = a[i];
    a[0] = x;
}

int getPoint( int* a )
{
    int x = 10000000;
    int sum = 0;
    for( int i = 0; i < 8; i++ )
    {
        sum += a[i] * x;
        x /= 10;
    }
    return sum;
}

int getPossibleNumber( int a, int b )
{
    if( a - b < 0 )
        return a;
    else
        return b;
}

int main()
{
    int p[8];

    while( cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7] )
    {
        int c[8] = { 4, 1, 4, 1, 2, 1, 2, 1 };
        int sum[8] = {}, max = 0, min2 = 1000000000;
        int res[8];
        for( int i = 0; i < 8; i++ )
        {
            for( int j = 0; j < 8; j++ )
                sum[i] += getPossibleNumber( p[j], c[j] );
            if( sum[i] > max )
            {
                for( int j = 0; j < 8; j++ )
                    res[j] = c[j];
                max = sum[i];
                min2 = getPoint(c);
            }
            else if( sum[i] == max && getPoint(c) < min2 )
            {
                for( int j = 0; j < 8; j++ )
                    res[j] = c[j];
                min2 = getPoint(c);
            }
            rotate(c);
        }
        for( int i = 0; i < 7; i++ )
            cout << res[i] << " ";
        cout << res[7] << endl;
    }
    return 0;
}
