atcoder#ABC215H. [ABC215H] Cabbage Master
[ABC215H] Cabbage Master
Score : points
Problem Statement
Takahashi, a cabbage farmer, has grown brands of cabbages, called Brand through Brand . He has heads of cabbage of Brand . Here, all heads of cabbages are distinguishable. He has clients called Company through Company . Company has ordered heads of cabbages. Different companies accept different brands of cabbages. For each pair ,
- if , cabbage of Brand can be shipped to Company ;
- if , cabbage of Brand cannot be shipped to Company .
Takahashi will be called a Cabbage Master if he succeeds in deciding where to ship the heads of cabbages so that or more heads of cabbages will be shipped to every company .
Snuke has decided to choose and eat zero or more heads of cabbages so that Takahashi cannot get the title of Cabbage Master, regardless of where to ship his cabbages. He does not like cabbage very much, so he will choose to eat the minimum number of heads of cabbages needed to achieve his objective.
Print the number of heads of cabbages Snuke will eat, and the number of ways, modulo , for Snuke to choose heads of cabbages to eat. Two ways to choose heads of cabbages are considered different when there is a head of cabbage that is eaten in one way but not in the other. Here, remember that any two heads of cabbages are distinguishable even if they are of the same brand.
Constraints
- For every , there exists such that .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print , the number of heads of cabbages Snuke will eat, and , the number of ways for Snuke to choose heads of cabbages to eat, modulo , in this order, with a space in between.
3 2
2 2 5
3 4
1 0
1 1
0 1
2 6
Snuke will eat two heads of cabbages to prevent Takahashi from becoming a Cabbage Master. There are six such ways to choose heads of cabbages to eat, as shown below, where denotes the -th head of cabbage of Brand .
1 1
3
4
1
0 1
It is possible that Takahashi is unable to become a Cabbage Master even if Snuke eats no cabbage. Then, Snuke will eat zero heads of cabbages, and there is just one way for him to choose heads of cabbages to eat: do not eat anything.
1 3
100
30 30 30
1 1 1
11 892328666
For the number of ways for Snuke to choose heads of cabbages to eat, be sure to print it modulo .