Sahih Muslim Book 36, Hadith Number 6609.

Chapter : The story of the three persons of the cave and their making good deeds of theirs as the means of riddance.

Abdullah b ‘Umar reported: I heard Allah’s Messenger (may peace be upon him) as saying: Three persons belonging to the earlier Ummahs set out on a journey until they had to spend a night in a cave. The rest of the hadith is the same and the additional words are: “A person amongst them said: O Allah, I had my aged parents and I served them milk before I (served that) to my wife, children and my servants.” And in case of the second one, the words are: “She avoided me until she was hard pressed because of famine and she came to me and I gave her one hundred and twenty dinars ” And in cease of the third one (the words are): “I invested his wages, and it brought profit and, as a result thereof, the merchandise increased and there was abundance of goods.” And he (the narrator said) that they got out of the cave and began to walk.