Which sentence has the correct pronoun and antecedent agreement?

The dogs wagged their tails.

Because the brothers were tired, he forgot to shut the gate and the dogs ran out.

When the teachers arrived at school, she saw the students writing with chalk.

The cat is sitting in the windowsill, and them is basking in the sun.

The dogs wagged their tails.