A and B each have a certain number of mangoes. A says to B, "if you give 30 of your mangoes, I will have twice as many as left with you." B replies, "if you give me 10, I will have thrice as many as left with you." How many mangoes does each have?