#include <bits/stdc++.h>
int main() {
  int T[5];
  int time[5][5];
  int total[] = {0, 0, 0, 0, 0};
  int min = 1000;
  int ID;
  scanf("%d", &T[0]);
  scanf("%d", &T[1]);
  scanf("%d", &T[2]);
  scanf("%d", &T[3]);
  scanf("%d", &T[4]);
  for (int i = 0; i < 5; i++) {
    printf("%d\t", T[i]);
  }
  printf("\n\n");
  for (int j = 0; j < 5; j++) {
    for (int k = 0; k < 5; k++) {
      if (j == k) {
        time[j][k] = T[k];
        printf("%d\t", time[j][k]);
      } else {
        time[j][k] = T[k] / 10 * 10;
        if (T[k] % 10 != 0) {
          time[j][k] += 10;
        }
        printf("%d\t", time[j][k]);
      }
    }
    printf("\n");
  }
  printf("\n");
  for (int l = 0; l < 5; l++) {
    for (int m = 0; m < 5; m++) {
      total[l] += time[l][m];
    }
    if (total[l] < min) {
      min = total[l];
    }
    printf("%d\t", total[l]);
  }
  printf("\nmin = %d", min);
  return 0;
}
