This page is still under construction.

Parts of this page are still being built. What you see may change.

Election Night

Interview

Time limit1sMemory limit128 MB

Summary
Each state is already won or has a set of possible winners; decide for every candidate whether they win the electoral college in all, some, or no assignment of undecided states.
Level

Medium6 of 10

Topics
Greedy, Math, Brute force, Implementation
Solved
No attempts yet

Problem

The nation of Cicoci elects its president with a winner-take-all electoral system. There are NN states, and each state casts exactly one electoral vote. A state's electoral vote goes to the candidate who wins the most popular votes in that state. The candidate who collects the most electoral votes becomes president. If two or more candidates are tied for the most electoral votes, no president is elected.

As the returns come in, the winner of some states is already decided, while others are still too close to call: in such a state, any one of several candidates could still win. Considering every way the undecided states might turn out, determine for each candidate whether that candidate is guaranteed to become president, could still become president, or cannot become president any more.

Formally, an outcome assigns to every state exactly one of the candidates who can still win that state (a state whose winner is already decided keeps that winner). For each candidate, report one of three verdicts:

  • the candidate becomes president in every possible outcome;
  • the candidate becomes president in at least one outcome, but not in every outcome;
  • the candidate becomes president in no outcome.

Input

The input contains several test cases. The first line of a test case has two positive integers NN and CC: the number of states and the number of candidates. Neither exceeds 100100. Each of the next NN lines describes one state: it starts with an integer kk, the number of candidates who might still win that state, followed by the kk identifiers of those candidates. Candidates are numbered with consecutive integers from 11 to CC.

The input ends with a line containing two zeros (00 00), which is not a test case and must not be processed.

Output

For each test case, consider the candidates in ascending order of their number. For candidate XX, print exactly one of the following lines, whichever applies:

Candidate X will become president.
Candidate X may become president.
Candidate X will not become president.

Print will when the candidate becomes president in every possible outcome, may when the candidate becomes president in some but not all outcomes, and will not when the candidate can never become president. Separate the output of consecutive test cases with a blank line.

Examples4

  1. Example 1

    Input
    4 5
    3 1 2 3
    3 1 3 4
    1 2
    1 2
    0 0
    
    Expected output
    Candidate 1 will not become president.
    Candidate 2 may become president.
    Candidate 3 will not become president.
    Candidate 4 will not become president.
    Candidate 5 will not become president.
    
  2. Example 2

    Input
    1 1
    1 1
    0 0
    
    Expected output
    Candidate 1 will become president.
    
  3. Example 3

    Input
    3 2
    2 1 2
    1 1
    1 1
    0 0
    
    Expected output
    Candidate 1 will become president.
    Candidate 2 will not become president.
    
  4. Example 4

    Input
    2 2
    2 1 2
    2 1 2
    0 0
    
    Expected output
    Candidate 1 may become president.
    Candidate 2 may become president.