#include <stdio.h>

int main() {
    int n;

    // Read the size of the square matrix
    scanf("%d", &n);

    // Check for invalid input (negative n)
    if (n < 0 || n > 10) { // Added n > 10 check based on constraints
        printf("Invalid Input\n");
        return 0;
    }

    int matrix;
    long long sum = 0; // Use long long for sum to prevent overflow for larger sums, though int might suffice given constraints
    long long product = 1; // Use long long for product to prevent overflow

    // Read matrix elements and calculate sum and product of diagonal elements
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &matrix[i][j]);
            // Check for invalid input (matrix element outside constraints)
            if (matrix[i][j] < -10 || matrix[i][j] > 10) {
                printf("Invalid Input\n");
                return 0;
            }
            if (i == j) { // Check if it's a diagonal element
                sum += matrix[i][j];
                product *= matrix[i][j];
            }
        }
    }

    // Print the sum and product
    printf("Sum:%lld\n", sum);
    printf("Product:%lld\n", product);

    return 0;
}