#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

int convert( int C[8] ) {
    int answer = 0;
    for ( int i = 0; i < 8; i++ ) {
        answer += C[i] * pow( 10, 8-i-1 );
    }
    return answer;
}

void rotate( int C[8] ) {
    int front = C[0];
    for ( int i = 1; i < 8; i++ ) {
        C[i-1] = C[i];
    }
    C[7] = front;
}

int main() {
    int P[8];
    while ( cin >> P[0] ) {
        for ( int i = 1; i < 8; i++ ) {
            cin >> P[i];
        }
        int C[8] = { 1, 2, 1, 2, 1, 4, 1, 4 };
        int answer[8];
        bool first = true;
        int minc;
        int mind;
        for ( int i = 0; i < 8; i++ ) {
            int c = 0;
            for ( int i = 0; i < 8; i++ ) {
                if ( P[i] - C[i] > 0 ) {
                    c += P[i] - C[i];
                }
            }
            if ( first || c < minc ) {
                first = false;
                minc = c;
                mind = convert( C );
                for ( int i = 0; i < 8; i++ ) {
                    answer[i] = C[i];
                }
            } else if ( c == minc ) {
                int d = convert( C );
                if ( d < mind ) {
                    first = false;
                    minc = c;
                    mind = d;
                    for ( int i = 0; i < 8; i++ ) {
                        answer[i] = C[i];
                    }
                }
            }
            rotate( C );
        }
        for ( int i = 0; i < 8; i++ ) {
            cout << answer[i];
            if ( i + 1 < 8 ) cout << " ";
        }
        cout << endl;
    }
    return 0;
}