Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/matritsa-pastki-uchburchakmi

Lower triangular matrix?

Easy 1000 ms 64 MB 32%
Share

A square matrix of size $n \times n$ is given. A matrix is called lower triangular if all elements above the main diagonal ($a_{i,j}$ with $j \gt i$) are zero. If it is, print YES, otherwise print NO.

A square matrix: the cells above the main diagonal are zeros, the ones below are arbitrary

Input

The first line contains a positive integer $n$.
Each of the next $n$ lines contains $n$ integers — the matrix.

Output

YES or NO.

Note

$1 \le n \le 100$
$-1000 \le a_{i,j} \le 1000$

Examples

Input #1
3
4 0 0
2 -1 0
5 3 7
Output #1
YES
Input #2
2
1 2
0 3
Output #2
NO

Sign in to submit a solution

Signing up is free and takes a minute.