A and B each has some money. If A gives Rs 30 to B, then B will have twice the money left with A. But, if B gives Rs 10 to A, then a will have thrice as much as is left with B. How much money does each have?