#abc244e. [abc244_e]King Bombee
[abc244_e]King Bombee
Problem Statement
You are given a simple undirected graph with vertices and edges. The vertices are numbered from through , and the edges are numbered from through . Edge connects Vertex and Vertex .
You are given integers , and . How many sequences are there satisfying the following conditions?
- is an integer between and (inclusive).
- There is an edge that directly connects Vertex and Vertex .
- Integer appears even number of times (possibly zero) in sequence .
Since the answer can be very large, find the answer modulo .
Constraints
- All values in input are integers.
- If , then .
Input
Input is given from Standard Input in the following format:
Output
Print the answer modulo .
Sample Input 1
4 4 4 1 3 2
1 2
2 3
3 4
1 4
Sample Output 1
4
The following sequences satisfy the conditions:
On the other hand, and do not, since there are odd number of occurrences of .
Sample Input 2
6 5 10 1 2 3
2 3
2 4
4 6
3 6
1 5
Sample Output 2
0
The graph is not necessarily connected.
Sample Input 3
10 15 20 4 4 6
2 6
2 7
5 7
4 5
2 4
3 7
1 7
1 4
2 9
5 10
1 3
7 8
7 9
1 6
1 2
Sample Output 3
952504739
Find the answer modulo .