וְכֹל֙ הַטַּ֣ף בַּנָּשִׁ֔ים אֲשֶׁ֥ר לֹא־יָדְע֖וּ מִשְׁכַּ֣ב זָכָ֑ר הַחֲי֖וּ לָכֶֽם׃
But all the women children, that have not known man by lying with him, keep alive for yourselves.
Read midrashic interpretation of Numbers 31:18: and classical rabbinic exegesis.