I read the editorial of this problem and I'm struggling to understand why the matrix construction works. I think the editorial is poor because proving it is important, and it's far from trivial for me. How does this ensure there is the same number of ones in every column? I get that by picking $$$d$$$ such that $$$dn \equiv 0 \; mod \; m$$$, the pattern repeats after (at least) $$$n$$$ rows, but I don't really know what's happening in between.
This comment explains the choice of $$$d = a$$$ which (I think) I understand intuitively but may not be a proof and I can't really see how it would work for other values of $$$d$$$, and this comment is a proof but for a different approach unfortunately. And, as a bonus, this comment shares my frustration with the problem.
Can someone prove it? Thank you.