The situation in the rope is given below,

The velocity of the wave at the bottom of the rope is given by,
v=μT; where T is tension and μ is linear mass density of the string.
v1=m1m2gL
Hence, the wavelength for frequency f will be,
λ1=fv1=f1m2m2gL
Similarly, at top the velocity will be,
v1=m1(m1+m2)gL
And, the wavelength will be,
λ2=f1m1(m1+m2)gL
Hence, the ratio of both wavelengths will be,
λ1λ2=m2m1+m2.