Let x the amount invested in fund B, then, you have that fund B returned 0.1*x (10% of the investment ) and fund A returned 0.03*4000 = 120 (3% of the investment)
Moreover, both funds returned together 8%, that is, it returned
0.08*(x + 4000).
Now, consider that amount returned by both funds equal the sum of the amount returned by each fund, then, you have:
0.1x + 120 = 0.08(x + 4000) expand the factor right side
0.1x + 120 = 0.08x + 320 subtrac 0.08x and subtract 120 both sides
0.1x - 0.08x = 320 - 120 simplify like terms
0.02x = 200 divide by 0.02 both sides
x = 200/0.02
x = 10000
Hence, the investment in fund B was $10000