By the Law of Conservation of Mass, in a chemical reaction no matter can be created nor destroyed, so the mass have to be the same before and after the reaction.
Before the reaction, we had 10 grams of A and 7 grams of B, so the total mass at the beginning is 17 grams. If all A and B reacted to form AB, we will have 0 grams of both A and B, so all the 17 grams have to be of compound AB.
So, the most correct alternative is 17 grams.