A toy is made up of N vertices and M undirected edges in the 2D plane. As usual, you want to know how many ways there are to color the vertices of the toy. You have totally C colors. And of course, to make things fun, you think that if one color configuration can be rotated to get another, these two configurations should be considered the same. Rotation means 2D in-plane rotation and reflection is not considered as rotation.
For instance, consider coloring the following toy with 2 colors. The coordinates of the vertices are:
1. (0,0)
2. (1,0)
3. (0,1)
4. (-1,0)
5. (0,-1)
The toy has 6 edges: (1,2), (1,3), (2,3), (3,4), (4,5), (5,2).
As a 2D being, this toy has no symmetry. So there are 32 ways to color it. Had the first two edges been removed, there would be only 12 different ways.
You should output the answer modulo 10
9 + 7.