#Lutece1159. Easy problem ( trust me
Easy problem ( trust me
Migrated from Lutece 1159 Easy problem ( trust me
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Given a Directed acyclic graph (DAG) with () nodes and edges.
There is a set which contains () distinct integers. Each node has a set that contains some distinct integers (possibly empty).
The Directed acyclic graph is legal only if the set of each node is a subset of and is a subset of nodes which can directly arrive it.
You are supposed to calculate how many kinds of graphs are legal. Calculate the answer mod .
Two graphs are considered different if there is at least one node in two graphs has different set.
See Hint for more understanding.
Input
The first line contains three integers () and , ().
The second lines contains two integers and (), representing that there is a direct edge from to
It is guaranteed that the given graph is a simple graph without multiple edges.
Output
Output the answer mod .
Samples
4 4 2
1 2
2 3
1 3
3 4
25
Note
Let consider the following sample.
There are 2 nodes and 1 edges that is 1--->2. And =2, that means contains 2 integers.
the set of node 2 must be a subset of node 1.
the set of node1 must be a subset of node
if S={1, 2}, then , let S1 be the set of node 1, S2 be the set of node2
S1={1 ,2} S2={1, 2}
S1={1 ,2} S2={ 1 }
S1={1 ,2} S2={ 2 }
S1={1 ,2} S2={ }
S1={ 1 } S2={ 1 }
S1={ 1 } S2={ }
S1={ 2 } S2={ 2 }
S1={ 2 } S2={ 0 }
S1={ } S2={ }
Therefore ,the answer is 9. There are 9 legal DAGs.
Resources
2015 UESTC ACM Summer Training Team Selection (4)