I just need to clear up what happens when the noun is one gender and the person represented by the noun is another.

The good male teacher said:
хорощий препадавтель сказал

The good female teacher said:
хорощая препадавтель сказала?

The good male orphan went home:
хорощий сирота шёл домой

The good female orphan went home:
хорощая сирота шла домой?

Basically; if the noun is masculine or common gender but the person represented by it is female (and vice versa) does either adjective or the verb follow the gender of the person or agree with the noun?

спасибо