int main()
{
  int a[] = {1,2,1,2,1,4,1,4};
  int p[8],i=0;
  while(cin >> p[(i++)%8])
  {
    if(i%8==0)
    {
      int ans=0, md = 1e5, dist;
      REP(j,8)
      {
        dist = 0;
        REP(k,8) 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;
        }
      }
      REP(j,8) printf("%d%s",a[(j+ans)%8],j==7?"\n":" ");
    }
  }
  return 0;
}