Deuteronomy 23:2-3

23:2 A person of illegitimate birth may not enter the assembly of the Lord; to the tenth generation no one related to him may do so.

23:3 An Ammonite or Moabite may not enter the assembly of the Lord; to the tenth generation none of their descendants shall ever do so,

Exodus 20:5-6

20:5 You shall not bow down to them or serve them, for I, the Lord, your God, am a jealous God, responding to the transgression of fathers by dealing with children to the third and fourth generations of those who reject me, 20:6 and showing covenant faithfulness to a thousand generations of those who love me and keep my commandments.