First, they must seek repentance in Allah. Second, they must perform the ghusl of janabah. Third, they must decide not to masturbate again.