Candy Bombers
Time limit1sMemory limit256 MB
Assign each pilot to at most one plane they can fly to maximize the number of planes sent.
Problem
When Germany was split into a part controlled by the Allies (France, England, the USA) and a part controlled by the Soviet Union, Berlin was divided as well. West Berlin belonged to West Germany, but the whole of Berlin sat inside East German territory, so no land route connected West Berlin to the rest of West Germany. After West Germany introduced a new currency, the Soviet Union cut every land and water connection from West Germany to West Berlin from 1948 to 1949. The Allies flew supplies from West Germany into West Berlin instead, and that operation is called the Air Bridge. Gail Halvorsen is credited with starting the practice: to entertain the children waiting for the planes, pilots dropped chocolate and other candy on small homemade parachutes. The planes became known as candy bombers.
Running an Air Bridge means solving several optimization problems. One of them is how to assign the planes and pilots you have so that as much weight as possible reaches the destination. Assume every plane carries the same amount of cargo. The goal is then to fly as many planes as you can.
You are given the list of planes and pilots currently available, and for each pilot the list of planes that pilot is able to fly. A pilot flies at most one plane, and a plane is flown by at most one pilot. Compute the largest number of planes that can be sent.
Input
The first line contains the number of data sets , with . Then data sets follow in the format below.
The first line of a data set contains two integers and . Here is the number of available planes, is the number of pilots, and . Then follow lines, one per pilot. The first number on line is the number of planes that pilot is capable of flying, with . It is followed by integers, each between and and all distinct, which are the planes pilot can fly.
Output
For each data set, first print Data Set x: on a line of its own, where x is the number of the data set, counting from 1. On the next line print the largest number of planes you can send. Print one blank line after the output of each data set.