Finite-beta minimum energy equilibria of RFPs, screw pinches and tokamaks