Genesis 38-40 NASB
24 Now it was about three months later that Judah was informed, "Your daughter-in-law Tamar has played the harlot, and behold, she is also with child by harlotry." Then Judah said, "Bring her out and let her be burned!" 25 It was while she was being brought out that she sent to her father-in-law, saying, "I am with child by the man to whom these things belong." And she said, "Please examine and see, whose signet ring and cords and staff are these?" 26 Judah recognized them, and said, "She is more righteous than I, inasmuch as I did not give her to my son Shelah." And he did not have relations with her again.
27 It came about at the time she was giving birth, that behold, there were twins in her womb. 28 Moreover, it took place while she was giving birth, one put out a hand, and the midwife took and tied a scarlet thread on his hand, saying, "This one came out first." 29 But it came about as he drew back his hand, that behold, his brother came out. Then she said, "What a breach you have made for yourself!" So he was named Perez. 30 Afterward his brother came out who had the scarlet thread on his hand; and he was named Zerah.
19 Now when his master heard the words of his wife, which she spoke to him, saying, "This is what your slave did to me," his anger burned. 20 So Joseph's master took him and put him into the jail, the place where the king's prisoners were confined; and he was there in the jail. 21 But the Lord was with Joseph and extended kindness to him, and gave him favor in the sight of the chief jailer. 22 The chief jailer committed to Joseph's charge all the prisoners who were in the jail; so that whatever was done there, he was responsible for it. 23 The chief jailer did not supervise anything under Joseph's charge because the Lord was with him; and whatever he did, the Lord made to prosper.
16 When the chief baker saw that he had interpreted favorably, he said to Joseph, "I also saw in my dream, and behold, there were three baskets of white bread on my head; 17 and in the top basket there were some of all sorts of baked food for Pharaoh, and the birds were eating them out of the basket on my head." 18 Then Joseph answered and said, "This is its interpretation: the three baskets are three days; 19 within three more days Pharaoh will lift up your head from you and will hang you on a tree, and the birds will eat your flesh off you."