Two friends A and B went to fruit market to buy some fruits. At first shop B bought some mangoes at a per mango and A bought 9 mangoes more than B. At the next shop A bought some apples at a unit price of l b per apple and B bought 18 apples more than A. Later, it was found that the ratio of number of fruits bought by A and B is 4 : 7, respectively, whereas the amounts of money spent by them to buy fruits are the same. Find the ratio a : b.