- محدودیت زمان: ۶ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
Ahlaam is a computer science student, doing her master thesis on a bioinformatics project about MicroRNAs, special molecule types found in cells. During her thesis, she wants to find microRNAs relevant to a specific health factor in human beings.
Ahlaam has designed microRNA ranking algorithms, each of which ranks microRNAs from a specific point of view. There are microRNAs numbered through , and each algorithm produces one permutation of these microRNAs. In the permutation produced by each algorithm, the first microRNA is inferred by the algorithm as the most relevant one to the health factor, and the last microRNA is inferred as the least relevant one.
Ahlaam wants to report a consensus ranking on microRNAs. In a consensus ranking, if microRNA is ranked before another mircroRNA , then at least half of the algorithms should have ranked before . Write a program to help Ahlaam find a consensus ranking.
ورودی
There are multiple test cases in the input. The first line of each test contains two space-separated integers () and (), the number of microRNAs and the number of ranking algorithms, respectively. Then, there are lines, where the -th line contains a permutation of numbers , representing the output of the -th ranking algorithm. The input terminates with a line containing which should not be processed.
خروجی
For each test case, print a single line containing a permutation of numbers , representing a possible consensus ranking. If there are more than one correct consensus rankings, print the first one in lexicographic order (a sequence is lexicographically less than a sequence iff there exists a positive integer such that for
all and ) . If no such a ranking exists, write No solution
instead.
مثال
ورودی نمونه ۱
خروجی نمونه ۱
ارسال پاسخ برای این سؤال