There are $3$ dinosaurs, $3$ hippos, $3$ flamingos, and $5$ giraffes. Find the number of ways to arrange the animals in a line such that each animal is next to at least one other animal of the same species.