Since you know that the median is 18 and the two middle values in the set are 17 and B, you know that B must be 19 to make the median 18. Knowing that, you can plug in different values for A that are between 7 and 12 and you would find that only a value of 9 makes the mean 17.
A=9 B=19