A Fully Self-Consistent Constraint on the Mass of M31 and the Local Group