// Add or remove includes
#include <iostream>
#include <vector>

using namespace std;

// Addapt the header of the function to your case
vector<int> suma_diagonal(const vector<vector<int>>& A, bool diagonal); 

// Addapt the call to 'function_name' and the way it is called to your case.
int main() {
  int n;
  while (cin >> n) {
    vector<vector<int> > A(n, vector<int>(n));
    for (int i = 0; i < n; ++i) 
        for (int j = 0; j < n; ++j) cin >> A[i][j];
    bool diagonal = true;
    vector<int> R = suma_diagonal(A,diagonal);
    for (int i = 0; i < 2*n-2; ++i) 
        cout << R[i] << ' ';
    cout << R[2*n-2] << endl;
    diagonal = false;
    R = suma_diagonal(A,diagonal);
    for (int i = 0; i < 2*n-2; ++i) 
        cout << R[i] << ' ';
    cout << R[2*n-2] << endl;
  }
}