Sample spreadsheet.xlsx
I have attached a spreadsheet that I need some formulas for.

In the J column, I would like it to look at which columns (D through G) have an X.
If it is just D, then I want it to return the value from cell N2.
If it is D plus just E, then I want it to return the value from cell O2.
If it is D plus just F, then I want it to return the value from cell P2.
If it is D plus E and F, then I want it to return the value from Q2.
If it is G, then I want it to return the value of 0

For column K, I would like it to look at the category in column C.
If the category is H, then I want it to divide the value from column J by 4.
All other categories would divide the value from column J by 2.

At the bottom of the spreadsheet, I have listed the separate categories in column I and would like it to total the monthly deduction from column J.
For example, J43 would just have the totals for those in category A (from column C).

I would really appreciate some help on this.

And just in case you are looking at Person 33, that person does not have to pay for insurance so there is no monthly deduction and the cells can just be left blank.