We are given a matrix $M \in \{0,1\}^{n\times n}$ satisfying the following property.
The rows and columns of $M$ can be partitioned into $k$ rowgroups and $k$ colgroups respectively, such that in each block $B \subseteq M$ induced by these partitions, whenever an entry $B_{i,j}$ is equal to $0$, all the entries of the $i$-th row or the $j$-th column of $B$ are equal to $0$ too.
Note that the entry assignment ($0$ or $1$) in each block $B$ of $M$ does not depend on the entry assignment in any other block.
Question: What is the maximum rank of $M$?
I only know the maximum rank of $M$ is upper bounded by $k^2$.