Given the set $X=\{1,2,\ldots,n\}$; $\,\,$ $n=mp=kq$ where $m,k,p,q$ are positive integers.
Please help me to programme an algorithm that realizes random generation of the following two partitions of $X$: $$ \mathcal{D}_{1} = \big\{A_{i}\big\}_{i=1}^{p}; \quad \bigcup_{i=1}^{p} A_{i} = X; \quad A_{i_{1}} \cap A_{i_{2}} = \emptyset \quad (i_{1} \neq i_{2}); \quad |A_{i}|=m, \quad i=\overline{1,p} $$ and $$ \mathcal{D}_{2} = \big\{B_{j}\big\}_{j=1}^{q}; \quad \bigcup_{j=1}^{q} B_{j} = X; \quad B_{j_{1}} \cap B_{j_{2}} = \emptyset \quad (j_{1} \neq j_{2}); \quad |B_{j}|=k, \quad j=\overline{1,q} $$ such that $$ A_{i} \cap B_{j} = \emptyset, \quad i=\overline{1,p}, \quad j=\overline{1,q}. $$
Here, as usual, $|S|$ denotes the number of elements of the set $S$.