Sometimes the best way to deal with this type of problem is to imagine a large number of candidates, say 5,000. How many of these write exam A? How many write exam B? Of those who write A, how many pass? Ditto for those who write B? Put all these numbers into a table.
So, the probability of passing is the number who pass A plus the number who pass B, all divided by 5000. You want a _conditional_ probability P(wrote A|pass). Can you see how to get that in terms of all the tabular entries?
Another way some people prefer is to draw a "tree diagram". In the first fork of the tree we have two branches "write A" and "write B". At the end of each of these two branches we have forks with additional branches "pass" or "fail". You can attach probabilities to each branch, then multiply them to get the probability at each of the four "tips".
A third way (which just formalizes the other two) is to use Bayes formulas; these are found in any textbook on the subject.
RGV