#K94912. Check Toeplitz Matrix

    ID: 38747 Type: Default 1000ms 256MiB

Check Toeplitz Matrix

Check Toeplitz Matrix

Given a 2D integer matrix, determine whether it is a Toeplitz matrix.

A matrix is said to be Toeplitz if every diagonal from the top-left to bottom-right contains the same element. In other words, for every element \(a_{i,j}\) (except those on the last row or column), it must hold that \(a_{i,j} = a_{i+1,j+1}\).

Your task is to read a matrix from standard input, check whether it satisfies the Toeplitz property, and output True if it does and False otherwise.

inputFormat

The first line of input contains two integers m and n, representing the number of rows and columns of the matrix respectively. This is followed by m lines, each containing n space-separated integers representing the elements of the matrix.

Note: An empty row (when n = 0) represents a valid row in the matrix.

outputFormat

Output a single line to standard output: True if the matrix is a Toeplitz matrix, and False otherwise.

## sample
3 4
1 2 3 4
5 1 2 3
9 5 1 2
True