The iron-rich minerals present in the magma align themselves with the already existing magnetic field of the Earth. When the magma starts to cool down, the iron rich minerals are the first to solidify first. The magnetic field of the Earth align these minerals as the needle of the compass. The alignment of these iron-minerals is fixed once the magma is solidified completely.
Hence, the given blanks can be filled with 'iron and solidify'. respectively.