#include <iostream>
#include <iomanip>
using namespace std;

const int NROW = 3; // number of rows
const int NCOL = 5; // number of columns

int main()
{
  int a[NROW][NCOL];
  int sum, row, col;
  // read values
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j < 5; ++j)
      cin >> a[i][j];

  // print values
  for(int i = 0; i < 3; ++i) {
    for(int j = 0; j < 5; ++j)
      cout << setw(5) << a[i][j];
    cout << endl;
  }

  cout << endl;
  
  row = 0;
  while(row < NROW)
   {
     sum = 0;
     for(col = 0; col < NCOL; col++)
       sum = sum + a[row][col]; 
     cout << "Sum of row " << row << " is " << sum << endl;
     row++;
   }

  cout << endl;
  col = 0;
  while(col < NCOL)
  {
    sum = 0;
    for(row = 0; row < NROW; row++)
      sum = sum + a[row][col];
    cout << "Sum of column " << col << " is " << sum << endl;
    col++;

  }
  return 0;
}

