Hadithcore
Musnad Ahmad 2216
hasan

It was narrated that Ibn ‘Abbas (رضي الله عنه) said:

Some of the prisoners on the day of Badr did not have any ransom, so the Messenger of Allah (ﷺ) made it their ransom to teach the children of the Ansar how to write. One day a boy came crying to his father, who said: What is the matter with you? He said: My teacher hit me. He said: The evil one is seeking vengeance for [the people thrown into] the well at Badr! By Allah, you will never go to him again.

References1 variant
Arabic/English book
Book 25, Hadith 2216