There are three heat transfers involved in this calorimetry problem.

#"heat to melt ice + heat to warm melt-water + heat lost by hot water" = 0#

#color(white)(mmmm)q_1 color(white)(mmll)+ color(white)(mmmmm)q_2 color(white)(mmmmmmm) + color(white)(mmmm)q_3color(white)(mmmmll) = 0#

#color(white)(mml)m_1Δ_text(fus)H color(white)(m)+ color(white)(mmm)m_1C_text(s)ΔT_2 color(white)(mmmmm)+ color(white)(mm)m_3C_text(s)ΔT_3color(white)(mmm) = 0#

Let's calculate each heat separately.

#q_1 = m_1Δ_text(fus)H = 20 color(red)(cancel(color(black)("g"))) × "333.55 J"·color(red)(cancel(color(black)("g"^"-1"))) = "6670 J"#

#q_2 = m_1C_text(s)ΔT_2 = 20 color(red)(cancel(color(black)("g"))) × "4.184 J"·color(red)(cancel(color(black)("g"^"-1")))"°C"^"-1" × (T_text(f) - "0 °C") = 83.7 T_text(f) color(white)(l)"J·°C"^"-1"#

#q_3 = m_3C_text(s)ΔT_3 = 120 color(red)(cancel(color(black)("g"))) × "4.184 J"·color(red)(cancel(color(black)("g")))·"°C"^"-1" × (T_text(f) - "49 °C") = 502T_text(f) color(white)(l)"J·°C"^"-1" - "24 600 J"#

Now, we add the three heats and combine like terms.

#q_1 + q_2 + q_3 = 6670 color(red)(cancel(color(black)("J" )))+ 83.7T_text(f) color(red)(cancel(color(black)("J")))·"°C"^"-1" + 502T_text(f) color(red)(cancel(color(black)("J")))·"°C"^"-1" - "24 600" color(red)(cancel(color(black)("J"))) = 0#

#586T_text(f)color(white)(l) "°C"^"-1" - "17 900" = 0#

#T_text(f) = "17 900"/("586 °C"^"-1") = "31 °C"#