He begs for his life and the queen says he can keep his life if he figures out what women like the most.
He goes around town trying to figure out what women like.
The night came back and told the queen what she asked of him. When she said that he was right the hideous woman wanted him to marry her.
He is miserable and he is speaking with her about how he doesn't want to be with her, she then said that if he wanted her to be pretty, then she would make herself beautiful but he would have to take the chance of other men chasing her for her looks.
She became beautiful and they lived happily ever after.