Consider two disjoint finite sets of positive integers, $A$ and $B$, have $n$ and $m$ elements, respectively. It is knows that all $k$ belonging to $A \cup B$ satisfies at least one of the conditions $k + 17 \in A$ and $k - 31 \in B$. Prove that $17n = 31m$.