Telecommunication Partners
Time limit1sMemory limit128 MB
Given an undirected graph and K, find the largest connected vertex set where each vertex has degree at least K inside the set.
Problem
An international telecommunication company wants to offer its business subscribers a discount on calls made to a fixed set of telephone numbers chosen by the client. From last year's call records, we say that two companies are Business Partners if one of them made or received a call to or from the other during the year.
Given the partnership relation among the companies and an integer , find the size (number of companies) of the largest set of companies that satisfies both of the following:
- Every company in has at least business partners that are also in (it may also have partners outside ).
- is connected: from any company in you can reach any other company in by following business-partner relationships that stay within .
If no such set exists, the answer is .
Input
The input consists of several test cases. The first line of each test case has three integers , , and . is the total number of companies subscribed to the service (); companies are identified by numbers from to . is the number of business-partner pairs, and is the minimum number of business partners each company must have inside the final set ().
Each of the next lines contains two integers and (, , ), meaning that companies and are business partners. The same pair may appear on more than one line, but it still counts as a single partnership.
A line whose first integer is marks the end of the input.
Output
For each test case, print a single line containing the size of the largest set that satisfies the conditions above.