סנהדרין י:ה · Sanhedrin 10:5

הַכֵּה תַכֶּה אֶת וְגוֹ' (דברים יג). הַחַמֶּרֶת וְהַגַּמֶּלֶת הָעוֹבֶרֶת מִמָּקוֹם לְמָקוֹם, הֲרֵי אֵלּוּ מַצִּילִין אוֹתָהּ. הַחֲרֵם אֹתָהּ וְאֶת כָּל אֲשֶׁר בָּהּ וְאֶת בְּהֶמְתָּהּ לְפִי חָרֶב (שם), מִכָּאן אָמְרוּ נִכְסֵי צַדִּיקִים שֶׁבְּתוֹכָהּ אוֹבְדִין, שֶׁבְּחוּצָה לָהּ פְּלֵטִין. וְשֶׁל רְשָׁעִים, בֵּין שֶׁבְּתוֹכָהּ בֵּין שֶׁבְּחוּצָה לָהּ, הֲרֵי אֵלּוּ אוֹבְדִין:
From the verse: “You shall smite the inhabitants of that city with the edge of the sword” (Deuteronomy 13:16), it is derived that the caravan of donkeys and the caravan of camels that move from place to place, these donkey or camel drivers save the city. If they were residing in the city for a period, they could join the minority of permanent residents who were not subverted to idol worship in order to create a majority and prevent the destruction of the city and its contents. It is stated: “Destroy it utterly, and all that is in it and its animals, with the edge of the sword” (Deuteronomy 13:16). From here, the Sages stated: The property of the righteous, who did not engage in idol worship, that is inside the city is destroyed with the rest of the city and its contents; but the property of the righteous that is outside the city is spared. And the property of the wicked, whether it is inside the city or whether it is outside the city, these items are destroyed.

Word-by-word Breakdown (מילים ושרשים)

הַכֵּה → You shall smite [נ - כ - ה]תַכֶּה → you shall smite [נ - כ - ה]אֶת → [object marker] וְגוֹ → etc. דברים → Deuteronomy [ד - ב - ר]יג → 13 הַחַמֶּרֶת → caravan of donkeys [ח - מ - ר]וְהַגַּמֶּלֶת → and the caravan of camels [ג - מ - ל]הָעוֹבֶרֶת → that passes [ע - ב - ר]מִמָּקוֹם → from place [מ - ק - ם]לְמָקוֹם → to place [מ - ק - ם]הֲרֵי → these אֵלּוּ → these [drivers] מַצִּילִין → save [צ - ל - ח / נ - צ - ל]אוֹתָהּ → it הַחֲרֵם → Destroy utterly [ח - ר - ם]אֹתָהּ → it וְאֶת → and all [כ - ל - ל]כָּל → all [כ - ל - ל]אֲשֶׁר → that בָּהּ → in it וְאֶת → and its animals [ב - ה - מ]בְּהֶמְתָּהּ → its animals [ב - ה - מ]לְפִי → with חָרֶב → sword [ח - ר - ב]שם → there מִכָּאן → from here אָמְרוּ → they stated [א - מ - ר]נִכְסֵי → property of [נ - כ - ס]צַדִּיקִים → righteous [צ - ד - ק]שֶׁבְּתוֹכָהּ → that is inside it [ת - ו - ך]אוֹבְדִין → is destroyed [א - ב - ד]שֶׁבְּחוּצָה → that is outside [ח - ו - ץ]לָהּ → of it פְּלֵטִין → is spared [פ - ל - ט]