Where are an insect's legs attached?

The legs are attached to the thorax.