3. Person A tosses a fair coin twice, and Person B tosses the same coin three times. If the probability that they end up with the same number of heads is written as a simplified fraction, the sum of the numerator and the denominator is $\qquad$ . (Romania)
3.21.

Let the outcomes of a coin landing heads up and tails up be denoted as $\mathrm{H}$ and $\mathrm{T}$, respectively.

Jia has four equally probable outcomes: HH, HT, TH, TT;

Yi has eight equally probable outcomes: HHH, HHT, HTH, THH, HTT, THT, TTH, TTT.
The outcomes that match $\mathrm{HH}$ are $\mathrm{HHT}$, $\mathrm{HTH}$, $\mathrm{THH}$; the outcomes that match $\mathrm{HT}$ or $\mathrm{TH}$ are HTT, THT, TTH,
and the outcome that matches TT is TTT.
Thus, the required probability is
$$
\frac{1}{4} \times \frac{3}{8} + \frac{1}{2} \times \frac{3}{8} + \frac{1}{4} \times \frac{1}{8} = \frac{5}{16},
$$

The sum of the numerator and the denominator is $5 + 16 = 21$.