Exploiting Factor and State Space Symmetry for Inference in Graphical Models