The role of AGB and RSG stars in the cycle of matter