As both A and B invest the same amounts, the ratio of their profits at the end of the year is equal to the ratio of the time periods for which they have invested.
Thus, the required ratio of their profits = A : B = 8 : 12 = 2 : 3.
Hence, share of A in the total profit = 2 x 25000/5 = Rs.10000
Similarly, share of B in the total profit = 3 x 25000/5 = Rs.15000