And it came to pass after these things, [that] the cup-bearer of the king of Egypt and the baker offended their lord the king of Egypt.
And Pharaoh was wroth with his two chamberlains -- with the chief of the cup-bearers and with the chief of the bakers;
and he put them in custody into the house of the captain of the life-guard, into the tower-house, into the place where Joseph was imprisoned.
And the captain of the life-guard appointed Joseph to them, that he should attend on them. And they were [several] days in custody.
And they dreamed a dream, both of them in one night, each his dream, each according to the interpretation of his dream, the cup-bearer and the baker of the king of Egypt, who were imprisoned in the tower-house.
And Joseph came in to them in the morning, and looked on them, and behold, they were sad.
References for Genesis 40:6
And he asked Pharaoh's chamberlains that were with him in custody in his lord's house, saying, Why are your faces [so] sad to-day?
References for Genesis 40:7
And they said to him, We have dreamt a dream, and there is no interpreter of it. And Joseph said to them, [Do] not interpretations [belong] to God? tell me [your dreams], I pray you.
Then the chief of the cup-bearers told his dream to Joseph, and said to him, In my dream, behold, a vine was before me;
and in the vine were three branches; and it was as though it budded: its blossoms shot forth, its clusters ripened into grapes.
And Pharaoh's cup was in my hand; and I took the grapes, and pressed them into Pharaoh's cup, and gave the cup into Pharaoh's hand.
And Joseph said to him, This is the interpretation of it: the three branches are three days.
In yet three days will Pharaoh lift up thy head and restore thee to thy place, and thou shalt deliver Pharaoh's cup into his hand, after the former manner when thou wast his cup-bearer.
References for Genesis 40:13
Only bear a remembrance with thee of me when it goes well with thee, and deal kindly, I pray thee, with me, and make mention of me to Pharaoh, and bring me out of this house;
for indeed I was stolen out of the land of the Hebrews, and here also have I done nothing that they should put me into the dungeon.
And when the chief of the bakers saw that the interpretation was good, he said to Joseph, I also was in my dream, and behold, three baskets of white bread were on my head.
References for Genesis 40:16
And in the uppermost basket there were all manner of victuals for Pharaoh that the baker makes, and the birds ate them out of the basket upon my head.
And Joseph answered and said, This is the interpretation of it: the three baskets are three days.
In yet three days will Pharaoh lift up thy head from off thee, and hang thee on a tree; and the birds will eat thy flesh from off thee.
And it came to pass the third day -- Pharaoh's birthday -- that he made a feast to all his bondmen. And he lifted up the head of the chief of the cup-bearers, and the head of the chief of the bakers among his bondmen.
And he restored the chief of the cup-bearers to his office of cup-bearer again; and he gave the cup into Pharaoh's hand.
And he hanged the chief of the bakers, as Joseph had interpreted to them.
But the chief of the cup-bearers did not remember Joseph, and forgot him.