In my logic course I saw the following equivalence, but I don't understand how they get there.$(\neg p\vee \neg q)\wedge(p\vee q)\, \Longleftrightarrow \, (\neg p\wedge p)\vee (\neg p\wedge q)\vee(\neg q\wedge p)\vee(\neg q\wedge q)$
I can see it's equivalent by setting up a truth table, but I just don't understand how they used the logical equivalence for distributivity which is $\varphi \vee (\psi \wedge \chi )\Longleftrightarrow (\varphi \vee \psi )\wedge (\varphi \vee \chi )$ to reach the formula on the right side.
Thanks in advance!