Since the ore 'A' of the metal gives CO2 upon heating, it is some metal carbonate (MCO3).
It can be converted to the metallic form as follows :
Since the ore 'Y' of the metal gives SO2 upon heating, it can be some metal sulphide (MS). It can be converted to the metallic form as follows :