#include <cstring>
#include <cstddef>
#include <iostream>
int main()
{
  int a[] = {1,2,1,2,1,4,1,4};
  int p[8],i=0,j, k;
  while(std::cin >> p[(i++)%8])
  {
    if(i%8==0)
    {
      int ans=0, md = 1e5, dist;
      for(j=0;j<8;j++)
      {
        dist = 0;
        for(j=0;j<8;j++) dist+=(p[k]>a[(k+j)%8])?p[k]-a[(k+j)%8]:0;
        if(dist == md)
        {
          int s1=0, s2=0;
          for(int k=0,d=1e7;k<8;k++,d/=10)
          {
            s1 += d*a[(k+ans)%8];
            s2 += d*a[(k+j)%8];
          }
          if(s2 < s1) ans = j;
        }
        if(dist < md)
        {
          md = dist;
          ans = j;
        }
      }
      for(j=0;j<8;j++) printf("%d%s",a[(j+ans)%8],j==7?"\n":" ");
    }
  }
  return 0;
}