Metamorphic rocks can be formed from sedimentary or igneous rocks. The sedimentary rocks particles form which a sedimentary rock is formed can be derived from a metamorphic, and igneous, or another sedimentary rock. All three types of rocks can be melted to form a magma.
Hope it helped a little:)