Distributivity mod an integer Let $a,b,c,m \in \mathbb{Z}$, is it always the case that $$a((b+c) \text{ mod } q) \text{ mod } q = (ab \text{ mod } q + ac \text{ mod } q) \text{ mod } q$$

Yes. When doing modular arithmetic you can take the modulus as often or seldom as you want to before you reach the final result, as long as you only do addition, subtraction and multiplication, and always end with a modulus. So your equation is equivalent to $a(b+c)\equiv ab+ac \pmod q$.
The formal justification for this is that when you're doing computations in $\mathbb Z/q\mathbb Z$, you can use any representative for each residue class you want for each operation, and the "mod $q$" just exchanges one representative for another for the same class. Only the final "mod $q$" is important; it ensures that if you have the same residue class on both sides, you will get the same representatives.
