var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   if(Arr.length==0)break;
   var arr=Arr.shift().split(" ").map(Number);
   var M=[1,4,1,4,1,2,1,2];
   var m=[];
   for(var i=0;i<M.length;i++){
      M.push(M.shift());
      m.push(M.join("")-0);
   }
   m.sort(function(a,b){return b-a;});
   m=m.map(function(v){return (v+"").split("").map(Number);});
   var min=Infinity;
   var ans;
   m.forEach(function(v,i){
      var sum=0;
      arr.forEach(function(V,I){
         if(v[I]<V)sum+=(V-v[I]);
      });
      min=Math.min(min,sum);
      if(min==sum)ans=i;
   });
   console.log(m[ans].join(" "));
}