import java.util.Scanner;
public class MatrixSumCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Read the size of the matrix
int n = scanner.nextInt();
// Create a matrix to store the integers
int[][] matrix = new int[n][n];
// Read the matrix from input
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
matrix[i][j] = scanner.nextInt();
}
}
// Calculate the sum of each row
int[] rowSums = new int[n];
for (int i = 0; i < n; i++) {
int rowSum = 0;
for (int j = 0; j < n; j++) {
rowSum += matrix[i][j];
}
rowSums[i] = rowSum;
}
// Calculate the sum of each column
int[] columnSums = new int[n];
for (int j = 0; j < n; j++) {
int columnSum = 0;
for (int i = 0; i < n; i++) {
columnSum += matrix[i][j];
}
columnSums[j] = columnSum;
}
// Output the results
System.out.println("Line Sums:");
for (int sum : rowSums) {
System.out.print(sum + " ");
}
System.out.println();
System.out.println("Column Sums:");
for (int sum : columnSums) {
System.out.print(sum + " ");
}
System.out.println();
scanner.close();
}
}