Coevolutionary dynamics in structured populations of three species