f=m(m/g^2) solve for m

Multiply both sides by g^2.

f(g^2) = m^2

Get square root of both sides.

m = g(√f)