The transformation of igneous rocks into sedimentary rocks

What is the source of energy that transforms igneous rocks into sedimentary rocks? What is the source of energy that transforms sedimentary rocks into metamorphic rocks? What is the source of energy that transforms metamorphic rocks into igneous rocks? Are these sources of energy internal or external? Explain.