#include<iostream>

using namespace std;

const string start = "14141212";
string s,outcome;

void make(){
  outcome = "999999999999";
  string tmp = "";

  for(int i = 0; i < (int)s.length(); i++)
    if(s[i] != ' ') tmp += s[i];

  s = tmp;
}

void calc(string now, int &out){

  int sum = 0;

  for(int i = 0; i < now.length(); i++){
    sum += max(0,s[i]-now[i]);
  }
  if(out == sum) outcome = min(outcome,now);
  else if(out > sum){
    out = sum;
    outcome = now;
  }
}

void solve(){
  make();
  string now = start;
  int out = (1<<20);

  while(1){
    calc(now,out);
    string tmp = now[now.length()-1]+now.substr(0,s.length()-1);
    now = tmp;
    if(now == start) break;		       
  }
  for(int i = 0; i < outcome.length(); i++){
    if(i) cout << " ";
    cout << outcome[i];
  }
  cout << endl;
}

bool input(){

  int data[8];
  s = "";
  for(int i = 0; i < 8; i++){
    if(!(cin >> data[i])) return false;
    s += data[i]+'0';
  }
  return true;
}
int main(){

  while(input()) solve();
  return 0;
}