Initially, bag A contains 9 white balls and 8 black balls.
So, total balls in bag A:
$$ 9 + 8 = 17 $$
Bag B contains 6 white balls and 4 black balls.
Total balls in bag B:
$$ 6 + 4 = 10 $$
One ball is randomly drawn from bag B.
Probability that the ball drawn from bag B is white:
$$ P(W_B)=\frac{6}{10}=\frac{3}{5} $$
Probability that the ball drawn from bag B is black:
$$ P(B_B)=\frac{4}{10}=\frac{2}{5} $$
Case 1: White ball is transferred from bag B to bag A.
Now, number of white balls in bag A becomes:
$$ 9 + 1 = 10 $$
Number of black balls remains:
$$ 8 $$
Total balls in bag A:
$$ 10 + 8 = 18 $$
Probability of drawing a white ball from bag A in this case:
$$ P(W_A|W_B)=\frac{10}{18}=\frac{5}{9} $$
Case 2: Black ball is transferred from bag B to bag A.
Now, number of white balls in bag A remains:
$$ 9 $$
Number of black balls becomes:
$$ 8 + 1 = 9 $$
Total balls in bag A:
$$ 9 + 9 = 18 $$
Probability of drawing a white ball from bag A in this case:
$$ P(W_A|B_B)=\frac{9}{18}=\frac{1}{2} $$
Using the law of total probability:
$$ P(W_A)=P(W_B)\cdot P(W_A|W_B)+P(B_B)\cdot P(W_A|B_B) $$
Substitute values:
$$ P(W_A)=\frac{3}{5}\cdot\frac{5}{9}+\frac{2}{5}\cdot\frac{1}{2} $$
$$ =\frac{3}{9}+\frac{1}{5} $$
$$ =\frac{5}{15}+\frac{3}{15} $$
$$ =\frac{8}{15} $$
Thus,
$$ \frac{p}{q}=\frac{8}{15} $$
So,
$$ p+q=8+15=23 $$
Hence, the correct answer is 23.
Updated for JEE Main 2026: This PYQ is important for JEE Mains, JEE Advanced and other competitive exams. Practice more questions from this chapter.