#P1799G. Count Voting
Count Voting
No submission language available for this problem.
Description
There are people that will participate in voting. Each person has exactly one vote.
-th person has a team () where means , are in the same team. By the rules each person should vote for the person from the different team. Note that it automatically means that each person can't vote for himself.
Each person knows the number of votes he wants to get. How many possible votings exists, such that each person will get the desired number of votes? Due to this number can be big, find it by modulo .
The first line contains a single integer () — the number of people.
The second line contains integers () — desired number of votes. It is guaranteed, that .
The third line contains integers () — team numbers.
Print a single integer — the number of possible votings by modulo .
Input
The first line contains a single integer () — the number of people.
The second line contains integers () — desired number of votes. It is guaranteed, that .
The third line contains integers () — team numbers.
Output
Print a single integer — the number of possible votings by modulo .
Note
In the first test there are two possible votings: , .
In the third test there are five possible votings: , , , , .