Let x be the months and y be the cost.
Rate of increase of commodity A = 6/3 = $2 per month
Equation:
y = 2x + 4500
Rate of increase of commodity B = 2/4 = $0.5 per month
Equation:
y = 0.5x + 5400
Equating the costs,
2x + 4500 = 0.5x + 5400
1.5x = 900
x = 600 months
x = 600 / 12 = 50 years