How does matter cycle and energy flow through the rock cycle?