Trips
Time limit0.5sMemory limit128 MB
Count assignments of N people to two trips, each internally a clique, at least A and B people, covering everyone, modulo 10007.
- Level
Hard8 of 10
- Topics
- Graph, Combinatorics, Dynamic programming
- Solved
- No attempts yet
Problem
The fire brigade of a small town has members, and not all of them know each other. The members are numbered with integers from to .
After a hard summer season of fighting fires, the brigade plans to go on two nature trips over the next two weekends.
The travel agency sent offers that are valid only if at least people go on the first trip and at least people go on the second trip. Also, to avoid awkward situations on the trips, every two people who take part in the same trip must know each other.
Firefighter Mirko has been given the job of assigning the members so that every member takes part in at least one trip and all the conditions above hold. A member may go on both trips.
Given the acquaintances between the members, write a program that computes the number of ways Mirko can make the assignment. Two ways are different if some member takes part in some trip in one way and not in the other.
Input
The first line contains four integers , , , and : the number of members of the brigade, the number of acquaintances between members, and the minimum numbers of people who must take part in the first and the second trip (, , ).
Each of the next lines contains two integers and (, ). Each line means that the members numbered and know each other. No acquaintance is given more than once.
Output
Print the total number of ways to assign the members to the trips on the first and only line. Because this number can be very large, print only its remainder when divided by .