Reference for Bekhorot 2:4
הַמְקַבֵּל צֹאן בַּרְזֶל מִן הַנָּכְרִי, וְלָדוֹת פְּטוּרִין, וּוַלְדֵי וְלָדוֹת חַיָּבִין. הֶעֱמִיד וְלָדוֹת תַּחַת אִמּוֹתֵיהֶם, וַלְדֵי וְלָדוֹת פְטוּרִין, וּוַלדי וַלְדֵי וְלָדוֹת חַיָּבִין. רַבָּן שִׁמְעוֹן בֶּן גַּמְלִיאֵל אוֹמֵר, אֲפִלּוּ עַד עֲשָׂרָה דוֹרוֹת, פְּטוּרִין, שֶׁאַחֲרָיוּתָן לַנָּכְרִי:
If one receives sheep at a fixed price from a non-Jew, its offspring are exempt from [the obligations of] the firstborn, but the second generation is obligated. If one offered the offspring as collateral for the mothers [should they die], then the second generation is exempt but the third generation is obligated. Rabban Shim'on ben Gamliel says: They are exempt even for ten generations, because the non-Jew has [residual] rights to them.