Despite [REDACTED] has caught up to him! Backed into a corner, 's only choice now is to wage war.
's escape plan,The battlefield is a sprawling plateau with towers. Some towers are connected by bridges and in total, bridges are present.
Letting his inner artist take over,
decides to paint all the towers. In order to make them visually appealing, he decides that no two directly connected towers should be painted the same colour.But before
can get started, Oscar, 's trusty aide, speaks up:Sir
, did you know that if you considered the towers as nodes and the bridges as edges then the battlefield is actually not guaranteed to be a connected graph?And also, each individual connected component either forms a tree or a graph with a single cycle.
responds:
No one asked. You're fired now.
Without his trusty aide by his side, he turns to you for help. Can you figure out the number of ways to colour the towers in each component, summed up?
Input Specification
The first line will contain the number of towers, , the number of bridges, , and the number of colours, .
The next lines will be in the form of , indicating that towers and are connected.
Output Specification
You are to output one number, the number of ways to colour the towers in each component, summed up, modulo .
Sample Input
8 7 3
1 2
2 3
3 4
4 2
5 6
6 7
6 8
Sample Output
36
Comments