Fictional Chemistry

View as PDF

Submit solution


Points: 1
Time limit: 1.0s
Memory limit: 256M

Problem types

Recently METU Lab of Fictional Chemistry has discovered four new particles: Harbenite (H), Polydenum (P), Radium (R) and Saronite (S). In order to create an element they have to use exactly two different particles. As the result they managed to get six new elements:

  • HP — Harbenite-Polydenum
  • HR — Harbenite-Radium
  • HS — Harbenite-Saronite
  • PR — Polydenum-Radium
  • PS — Polydenum-Saronite
  • RS — Radium-Saronite

In the Lab there are \(H\) particles of Harbenite, \(P\) particles of Polydenum, \(R\) particles of Radium and \(S\) particles of Saronite. Your task is to make as many elements as possible using the given particles.

Input

Four integers \(H\), \(P\), \(R\), \(S\) separated with single spaces.

Output

Print six integers separated with single spaces — the number of elements HP, HR, HS, PR, PS and RS respectively which can be made using the particles. The sum of these values should be maximal possible. If there are multiple optimal solutions print the one with the largest number of HP elements. If there is still a tie choose a solution with the largest number of HR elements, then — HS, then — RP, then — PS.

Constraints
  • \(0 ≤ H,P,R,S ≤ 1000000000(10^9)\)
Examples

Input (stdin)

1 2 3 4
0 4 7 47

Output(stdout)

1 0 0 0 1 3
0 0 0 0 4 7
Notes
  • In the first sample 5 elements can be made. However, if we made both element HP and element PR then the remaining set of particles (\(R, R, S, S, S, S\)) would allow only two elements.
  • In the second sample it's impossible to use all the particles.