Explanation:
(q and (not q or p)) = (q and not q) or (q and p) = false or q and p = q and p
(p and not (q and p)) = (p and (not q or not p)) =
= (p and not q) or (p and not p) = (p and not q) or false =
= p and not q
so, we have in total
(q and p) or (p and not q) = (p and q) or (p and not q).
this is p, because if p=false both brackets are false and therefore the whole expression is false. and if p=true, then one of the 2 brackets must be true, which makes the whole expression true.