#Lutece1309. Circular Table
Circular Table
Migrated from Lutece 1309 Circular Table
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There are people sit around a circular table with seats.
It's obvious that there will be ways to arrange their position, but the arrangement does not go well, because there are some pairs of people who are unwilling to sit with the another.
More precisely, the people numbered from to , and the relation of them can be described as unordered pairs , meaning that the people numbered and the people numbered will not sit in two adjacent positions.
The meaning of adjacent positions is, if we number seats from to clockwise, the seat number is adjacent to the seat number for all , in addition, the seat number is adjacent to the seat number .
How many ways to arrange their position while nobody is unwilling?
Input
The first line contains two integers and .
Then lines follow, each with two integers and . ()
It is guaranteed that every relation is mentioned no more than once.
Output
Print the number of ways to arrange their position while nobody is unwilling. As the answer may be too large, output it modulo (i.e. if the answer is , you should output ).
Samples
4 0
24
4 1
1 2
8
Resources
The 14th UESTC Programming Contest Final