A game of numbers has the following rules: at the beginning, two distinct positive integers are given by the judge. Then each player in turn must give a number to the judge. The number must be the difference of two numbers that are previously given, and must not be duplicated to any of the existed numbers. The game will run for several rounds. The one who gives a duplicate number or even a wrong number will be kicked out.

Your job is to write a judger program to judge the players’ numbers and to determine the final winners.

Input Specification:

Each input file contains one test case. For each case, the first line gives two distinct positive integers to begin with. Both numbers are in $[1,10^5]$.

In the second line, two numbers are given:  (), the number of players, and  (), the number of rounds.

Then  lines follow, each contains  positive integers. The -th line corresponds to the -th player (). The game is to start from the 1st player giving his/her 1st number, followed by everybody else giving their 1st numbers in the 1st round; then everyone give their 2nd numbers in the 2nd round, and so on so forth.

Output Specification:

If the i-th player is kicked out in the k-th round, print in a line Round #k: i is out.. The rest of the numbers given by the one who is out of the game will be ignored. If more than one player is out in the same round, print them in increasing order of their indices. When the game is over, print in the last line Winner(s): W1 W2 ... Wn, where W1 ... Wn are the indices of the winners in increasing order. All the numbers in a line must be separated by exactly one space, and there must be no extra space at the beginning or the end of the line. If there is no winner, print No winner. instead.

Sample Input 1:

101 42
4 5
59 34 67 9 7
17 9 8 50 7
25 92 43 26 37
76 51 1 41 40

Sample Output 1:

Round #4: 1 is out.
Round #5: 3 is out.
Winner(s): 2 4

Sample Input 2:

42 101
4 5
59 34 67 9 7
17 9 18 50 49
25 92 58 1 39
102 32 2 6 41

Sample Output 2:

Round #1: 4 is out.
Round #3: 2 is out.
Round #4: 1 is out.
Round #5: 3 is out.
No winner.

#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int N;//玩家数量
int M;//游戏轮次
int nums[11][1010];
int a;
int b;//裁判给出的两个数

bool exist[100010] = {0};//判断数是否存在
bool outs[11] = {0};//是否淘汰
bool difference[100010] = { 0 };
vector used;//保存已经出现过的数

int main() {
	cin >> a >> b;	
	cin >> M;
	cin >> N;
	fill(exist, exist + 100010, false);
	fill(outs, outs + 11, false);
	used.push_back(a);
	used.push_back(b);
	exist[a] = true;
	exist[b] = true;
	int used_index = 2;
	difference[abs(a - b)] = 1;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) { cin >> nums[i][j];
		}
	}
	for (int i = 0; i < N; i++) {//i表示轮数5
		for (int j = 0; j < M; j++) {//j表示玩家数量4
			if (outs[j] == true)
				continue;//如果是已经淘汰的人就不进行判断
			if (exist[nums[j][i]] == true) {//如果给出的数已经存在
				outs[j] = true;//淘汰
				printf("Round #%d: %d is out.\n",i+1,j+1);
				continue;
			}
			if (difference[nums[j][i]] == false) {//如果给出的数不是差值
				outs[j] = true;//淘汰
				printf("Round #%d: %d is out.\n", i + 1, j + 1);
				continue;
			}
			for (int k = 0; k < used.size(); k++) {//更新差值
				difference[abs(nums[j][i] - used[k])] = true;
					
			}
			exist[nums[j][i]] = true;
			used.push_back(nums[j][i]);

		}

	}
	int count = 0;//统计胜者数量
	for (int i = 0; i < M; i++) { if (outs[i] == 0)count++; } if (count > 0) {
		cout << "Winner(s):";
		for (int i = 0; i < M; i++) {
			if (outs[i] == 0)
				cout << ' ' << i+1;
		}
	}
	else cout << "No winner.";
}