#include <bits/stdc++.h>
using namespace std;
int main() {
  int dishes[5];
  for (int i = 0; i < 5; i++) cin >> dishes[i];
  int ans = 0;
  int tmp = 0;
  for (int i = 0; i < 5; i++) {
    if (dishes[i] % 10 != 0) {
      if (10 - (dishes[i] % 10) > tmp) tmp = 10 - (dishes[i] % 10);
    }
    cout << tmp << " ";
  }
  cout << endl;
  for (int i = 0; i < 5; i++) {
    ans += dishes[i];
    if (dishes[i] % 10 != 0) {
      ans += 10 - (dishes[i] % 10);
    }
    cout << ans << " ";
  }
  ans -= tmp;
  cout << ans << endl;
  return 0;
}
