<title>2015 Blue Bridge Cup: 9. Base Dice</title> 2015 Blue Bridge Cup: 9. Base Dice
25 cents won't write.
Gambling San ATM in the old age infatuated with the dice, is the dice one base on the other top, not crooked, to base solutionkeys column body.
After a long observation, ATM found the secret of stabilizing the dice: Some of the number of the surface will be mutually exclusive!
Let's start by standardizing the dice: 1 opposite is 4,2 opposite is 5,3 opposite is 6.
If there is an M-group mutex, the two-digit face of each group clings to one another, and the dice cannot stabilize the base.
The ATM wants to calculate how many different possible ways to base the dice.
The two types of dice are the same, and the corresponding numbers of the dice corresponding to the height of the two methods are the same.
Because the number of scenarios may be too large, output modulo 10^9 + 7 results.
Do not underestimate the number of ATM dice Oh ~
"Input Format"
First row of two integers n m
n indicates the number of dice
The next m line, two integers a b per line, indicates that A and B numbers cannot be glued together.
"Output Format"
A row of a number that represents the result of the answer modulo 10^9 + 7.
"Sample Input"
2 1
1 2
"Sample Output"
544
"Data Range"
For 30% data: N <= 5
For 60% data: N <= 100
For 100% data: 0 < n <= 10^9, M <= 36
2015 Blue Bridge Cup: 9. Base Dice