How to Solve?

Help Please
How to solve these type of question using bitmasking. and also other approach.