 Well, before the creation of the universe. God had this plan before the creation of the universe. And how would He know to have this plan? God is omniscient. He knew that men would sin. He foreknew specific cases of sin. Look at Judas. Look at Judas. Look at Pharaoh. Look at Pharaoh.