Hide

Problem I
k-Colouring of a Graph

You are given a simple graph with N nodes and M edges. The graph has the special property that any connected component of size s contains no more than s+2 edges. You are also given two integers k and P. Find the number of k-colourings of the graph, modulo P.

Recall that a simple graph is an undirected graph with no self loops and no repeated edges. A k-colouring of a graph is a way to assign to each node of the graph exactly one of k colours, such that if edge (u,v) is present in the graph, then u and v receive different colors.

Input

The first line of input consists of four integers, N,M,k, and P (1N50000, 0M1.5N, 1k109, 1P2109). The next M lines of input each contains a pair of integers A and B (1AN, 1BN), describing an edge in the graph connecting nodes A and B.

Output

Output the number of k-colourings of the given graph, modulo P.

Sample Input 1 Sample Output 1
3 3 2 10000
1 2
2 3
3 1
0
Sample Input 2 Sample Output 2
3 3 4 13
1 2
2 3
3 1
11
Hide

Please log in to submit a solution to this problem

Log in