Problems
There are
A nonempty subset of the cows will be selected to attend a field trip. If the ith cow is selected, the cow will move to position
A nonempty subset of the cows is called "good" if for every selected camper, there is a selected coach within
Input
The first line contains two integers
The next
th cow will move to.
It is guaranteed that the
Output
Output the number of good subsets modulo
Subtask
| # | Score | Condition |
|---|---|---|
| #1 | 10 | |
| #2 | 20 | |
| #3 | 30 | |
| #4 | 40 | No additional constraints. |
Example #1
6 1
3 1
4 0
6 1
7 1
9 0
10 0
11
The last two campers can never be selected. All other nonempty subsets work as long as if cow
Example #2
20 24
3 0
14 0
17 1
20 0
21 0
22 1
28 0
30 0
32 0
33 1
38 0
40 0
52 0
58 0
73 0
75 0
77 1
81 1
84 1
97 0
13094