#!/usr/bin/ruby
# coding: utf-8

PI = Math.acos(-1)
EPS = 0.00001

it = [4,1,4,1,2,1,2,1]

def dif(xs, ys)
  r = 0
  for i in 0...xs.length
    r += [xs[i], ys[i]].min
  end
  r
end

def less(xs, ys)
  for i in 0...xs.length
    if xs[i] < ys[i]
      return true
    elsif xs[i] > ys[i]
      return false
    end
  end
  return false
end

while true
  line = gets
  break if line == nil
  that = line.chomp.split.map{|x| x.to_i}

  mx = -1
  res = []
  for i in 0...10
    it.rotate!
    m = dif(it, that)
    if (m > mx) or ((m == mx) and (less it, res))
      mx = m
      res = it.clone
    end
  end
  puts res.join(' ')
end