Given $r$ numbers $a\_1,a\_2,...,a\_r$ and $n=qP$ where $P$ is the product of these $r$ numbers. $q$ is a natural number such that $q \geq 2$.


Also given is a matrix $A$ of the following form: $$A=\begin{pmatrix}x\_{11}&x\_{12}&...&x\_{1r}\\x\_{21}&x\_{22}&...&x\_{2r}\\:&:&:&:\\x\_{n1}&x\_{n2}&...&x\_{nr}\end{pmatrix}.$$ Here all $x\_{ij}$'s are either $0$ or $1$. Each row has exactly one $1$ and each column sums up to some multiple of $a\_j$, where $j$ is the column number.


Also, the sum of all elements of the matrix is equal to $n$, as defined above.



> 
> Allowing rearrangement of rows of $A$, how do I show that for each $j = 1, 2, · · · , r$, the sum of the first $P$ terms in the $j^{th}$ column of the matrix $A$ can be made a multiple of $a\_j$? 
> 
> 
> 


I know that it can be done by repeatedly applying the [EGZ theorem](https://www.renyi.hu/~p_erdos/1961-25.pdf), but I fail to see how.


Note: This is part of a bigger problem that I am solving, and this is all the relevant context that is required.



Application of the EGZ theorem
We may not care that elements are zeroes or ones. By EGZ applied to a first column (several times) we may partition rows to $n/a\_i$ blocks so that the sum in each block is divisible by $a\_i$. Now we consider only permutations for which these blocks are consecutive. Consider the second column, we have $n/a\_i$ numbers (sums in blocks), they may be partitioned onto $n/a\_1a\_2$ superblocks of cardinality $a\_2$ so that sum in each superblock is divisible by $a\_2$. Proceed this way or use induction.


