#include <iostream>
using namespace std;
int main(){
int n, i, j, a[100][100];
cin >> n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
cin >> a[i][j];
int prod=1;
//Diagonala principala
for(i=1;i<=n;i++) prod*= a[i][i];
cout << prod;
prod=1;
//Diagonala secundara
for(i=1;i<=n;i++) prod*= a[i][n-i+1];
cout << " " << prod;
}