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, 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.