#ABC244E. [ABC244E] King Bombee
[ABC244E] King Bombee
Score : points
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.
- $1 \leq U_i
- If , then .
Input
Input is given from Standard Input in the following format:
Output
Print the answer modulo .
The following sequences satisfy the conditions:
On the other hand, and do not, since there are odd number of occurrences of .
The graph is not necessarily connected.
Find the answer modulo .