eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Condorcet Winners

Condorcet Winners

Ліміт часу 5 секунд
Ліміт використання пам'яті 64 MiB

A Condorcet winner of an election is a candidate who would beat any of the other candidates in a one-on-one contest. Determining a Condorcet winner can only be done when voters specify a ballot listing all of the candidates in their order of preference (we will call such a ballot a preference list). For example, assume we have 3 candidates - A, B and C - and three voters whose preference lists are ABC, BAC, CBA. Here, B is the Condorcet winner, beating A in 2 of the three ballots (ballots 2 and 3) and beating C in 2 of the three ballots (1 and 2).

The Condorcet voting system looks for the Condorcet winner and declares that person the winner of the election. Note that if we were only considering rst place votes in the example above (as we do in most elections in the US and Canada), then there would be a tie for rst place. There can be at most only one Condorcet winner, but there is one small drawback in the Condorcet system - it is possible that there may be no Condorcet winner.

Вхідні дані

Input for each test case will start with a single line containing two positive integers bc, where b indicates the number of ballots and c indicates the number of candidates. Candidates are considered numbered 0, ..., c-1. Following this first line will be b lines containing c values each. Each of these lines represents one ballot and will contain the values 0, ..., c-1 in some permuted order. Values of b and c will lie in the ranges 1...500 and 1...2500, respectively, and the line 0 0 will follow the last test case.

Вихідні дані

For each test case output a single line containing either the candidate number of the Condorcet winner, or the phrase No Condorcet winner using the format given.

Приклад

Вхідні дані #1
3 3
0 1 2
1 0 2
2 1 0
3 3
0 1 2
1 2 0
2 0 1
0 0
Вихідні дані #1
Case 1: 1
Case 2: No Condorcet winner
Джерело 2011 East Central Regional Contest