Extensions and Limits of the Specker-Blatter Theorem