The dwelling-place of all the cattle and animals was in the lowest compartment, the dwelling-place for all fowl was in the second compartment, and the dwelling-place for the reptiles and the human beings was in the third compartment. Hence thou mayest learn that there were 366 kinds of cattle on the earth, and 366 kinds of fowl on the earth, and 366 kinds of reptiles on the earth, for thus was (the number) in the lowest compartment, so in the second compartment, and so in the third floor, as it is said, "With lower, second, and third stories shalt thou make it" (Gen. 6:16).
Rabbi Eliezer Teaches
Pirkei DeRabbi Eliezer 23:2