// Aeroporto
#include <stdio.h>

#define AEROPORTOS 105

int main() {
	int teste;
	int aeroportos, voos, partida, chegada;
	int congestionamento[AEROPORTOS], maiorcongestionamento;
	int i;

	for (teste=1; scanf("%d %d", &aeroportos, &voos)&&(aeroportos!=0||voos!=0); teste++) {
		printf("Teste %d\n", teste);
		maiorcongestionamento=0;
		for (i=1; i<=aeroportos; i++) {
			congestionamento[i]=0;
		}
		for (i=0; i<voos; i++) {
			scanf("%d %d", &partida, &chegada);
			congestionamento[partida]++;
			congestionamento[chegada]++;
			if (congestionamento[partida]>maiorcongestionamento) {
				maiorcongestionamento=congestionamento[partida];
			}
			if (congestionamento[chegada]>maiorcongestionamento) {
				maiorcongestionamento=congestionamento[chegada];
			}
		}
		for (i=1; i<=aeroportos; i++) {
			if (congestionamento[i]==maiorcongestionamento) {
				printf("%d ", i);
			}
		}
		printf("\b\n\n");
	}

	return 0;
}

