The gender of an animate noun is defined by the gender of the noun itself (мужчина – он, женщина – она). The gender of an inanimate noun is defined by the ending (дом – он, сумка – она). Animals take their gender like inanimate nouns, not by whether they are female or male (собака – она).