Let
k=CMAM. Triangles
ABM and
CBM share the altitude from
B, so
[CBM][ABM]=k. Since the inradius of a triangle is its area divided by its semiperimeter, equal inradii force
13+CM+BM12+AM+BM=k as well. From
AM+CM=15 we get
AM=k+115k and
CM=k+115; since
AM=k⋅CM, the perimeter equation simplifies to
BM(1−k)=13k−12, so
BM=1−k13k−12, and
BM>0 forces
1312<k<1.
Stewart’s theorem on cevian
BM gives
AB2⋅CM+BC2⋅AM =AC(BM2+AM⋅CM), so
BM2=k+1144+169k−(k+1)2225k. Setting this equal to
(1−k)2(13k−12)2 and clearing denominators yields
(169k2+88k+144)(1−k)2 =(13k−12)2(k+1)2, which simplifies to
4k(69k2−112k+44)=0.
The roots are
k=0, k=32, and
k=2322, and only
k=2322 exceeds
1312 (then
AM=322, CM=323, BM=10). Hence
p+q=22+23=45.