The hinged rod is immersed in two layers: the lower half in density 6ρ and the upper half in density 2ρ. For a small angular displacement, the buoyant forces and weight create a net restoring torque proportional to θ.
The lower half is in the 6ρ liquid and the upper half is in the 2ρ liquid.
For small θ, each vertical force has perpendicular lever arm rθ.
The rod has I = mL²/3 = ρAL³/3 about the hinge.