atcoder#RELAY2I. Nice to Meet You
Nice to Meet You
Score : points
Problem Statement
There are islands floating in Ringo Sea, and travel agents operate ships between these islands. For convenience, we will call these islands Island and call these agents Agent .
The sea currents in Ringo Sea change significantly each day. Depending on the state of the sea on the day, Agent operates ships from Island to , or Island to , but not both at the same time. Assume that the direction of the ships of each agent is independently selected with equal probability.
Now, Takahashi is on Island , and Hikuhashi is on Island . Let be the probability that Takahashi and Hikuhashi can travel to the same island in the day by ships operated by the agents, ignoring the factors such as the travel time for ships. Then, is an integer. Find modulo .
Constraints
- All pairs are distinct.
Input
Input is given from Standard Input in the following format:
Output
Print the value modulo .
4 3
1 3
2 3
3 4
6
The scenarios shown above occur with equal probability, and Takahashi and Hikuhashi can meet on the same island in of them. Thus, and .
5 5
1 3
2 4
3 4
3 5
4 5
18
6 6
1 2
2 3
3 4
4 5
5 6
1 6
64