#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e;
cin >> a >> b >> c >> d >> e;
int eat=(a%3)+(b%3)+(c%3)+(d%3)+(e%3);
a-=(a%3);
b+=a/3;
e+=a/3;//
a=a/3;
b-=(b%3);
a+=b/3;
c+=b/3;//
b=b/3;
c-=(c%3);
b+=c/3;
d+=c/3;//
c=c/3;
d-=(d%3);
c+=d/3;
e+=d/3;//
d=d/3;
e-=(e%3);
d+=e/3;
a+=e/3;
e=e/3;
cout << a << " " << b << " " << c << " " << d << " " << e << endl;
cout << eat;
return 0;
}