Welcome to EP.
You are writing under "Electronic projects", does it mean you need to implement the circuit in the smallest, cheapest, easiest way?
If so, you can use the 74XXX283 IC for that.
If however your purpose is learning:
1. You could use the "head in the wall" approach of a truth table...