A can finish a piece of work alone in 6 days, while B can finish the same in 12 days. They start working together and A quits after 2 days. Then B works alone for 3 days and after 3 days, A is called back and he finishes the remaining work alone. If they are paid Rs. 1008 for the work, find the amount that each one gets assuming that the amount is distributed in the ratio of the amount of work that they do.