Is this a Weyr matrix? There's a type of n&times;n matrix W called the basic Weyr canonical form. Such a matrix is described by its blocks and has the following properties, using the following reference diagram:




the main diagonal blocks Wii are ni&times;ni matrices of the form &lambda;Ini where Ini is the ni&times;ni identity matrix.
n1 &ge; n2 &ge; ... &ge; nr
the first superdiagonal blocks Wk-1,k for k &in; 2..r are nk-1&times;nk matrices that are full column rank in row-reduced echelon form, or more simply put, Ink sitting on top of nk-1 - nk rows of zeros.
all other blocks are 0 matrices.


For example:




The main diagonal blocks (yellow) are such that the ni are 4, 2, 2, and 1.
The first superdiagonal blocks are in green.
The grey zone consists of all the other blocks, which are all 0.


For this challenge we will assume λ=1.

Input

A square matrix with 0s and 1s in any convenient format.

Output

Output one of two distinct values for whether the input matrix is Weyr or not Weyr.

Rules

This is code-golf. Fewest bytes in each language wins. Standard rules/loopholes apply.

Test cases

Presented as arrays of rows.

Weyr:

[[1]] 
[[1,1],[0,1]] 
[[1,0,1,0,0],[0,1,0,1,0],[0,0,1,0,1],[0,0,0,1,0],[0,0,0,0,1]]
[[1,0,0,1,0,0,0,0,0],[0,1,0,0,1,0,0,0,0],[0,0,1,0,0,1,0,0,0],[0,0,0,1,0,0,1,0,0],[0,0,0,0,1,0,0,1,0],[0,0,0,0,0,1,0,0,1],[0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,1,0],[0,0,0,0,0,0,0,0,1]]
[[1,0,0,0,1,0,0,0,0],[0,1,0,0,0,1,0,0,0],[0,0,1,0,0,0,0,0,0],[0,0,0,1,0,0,0,0,0],[0,0,0,0,1,0,1,0,0],[0,0,0,0,0,1,0,1,0],[0,0,0,0,0,0,1,0,1],[0,0,0,0,0,0,0,1,0],[0,0,0,0,0,0,0,0,1]]


Non-Weyr:

[[0]]
[[1,0],[1,1]]
[[1,0,0,1,0,0],[0,1,0,0,0,0],[0,0,1,0,0,1],[0,0,0,1,0,0],[0,0,0,0,1,0],[0,0,0,0,0,1]]
[[1,0,1,0,0],[0,1,0,0,0],[0,0,1,0,0],[0,0,0,1,0],[0,0,0,0,1]]
[[1,0,0,1,0,0,0,0,0],[0,1,0,0,1,0,0,0,0],[0,0,1,0,0,1,0,0,0],[0,0,0,1,0,0,0,0,0],[0,0,0,0,1,0,1,0,0],[0,0,0,0,0,1,0,1,0],[0,0,0,0,0,0,1,0,1],[0,0,0,0,0,0,0,1,0],[0,0,0,0,0,0,0,0,1]]
K (ngn/k), 91 88 84 80 81 bytes
{x~e|(-n)#'(0*x),'(!n)=\:,/(-1_b)+1_0{x#!y}':|-n-':|b:|\@[-1++/|\|+x|e:=n:#x;]\0}

Try it online!