import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(s;stdin.byLine())
    {
        immutable N = 8;
        auto c = s.split().map!(to!int).array();
        auto a = [4,1,4,1,2,1,2,1].cycle().take(N*2).array();
        int m=-1;
        int p;
        foreach(i;0..N)
        {
            auto V = zip(c,a[i..i+N]).map!(t=>min(t[0],t[1])).reduce!"a+b"();
            if(m<V) m=V,p=i;
        }
        a[p..p+N].map!(to!string).join(" ").writeln();
    }
}