#include <stdio.h>
#include <memory.h>
int main(void){
	int n,q,m,d,i,f[101],max,ans;
	while(1){
		scanf("%d %d",&n,&q);
		if(!n)
			break;
		memset(f,0,sizeof(f));
		max=ans=0;
		while(n--){
			scanf("%d",&m);
			while(m--){
				scanf("%d",&d);
				f[d]++;
			}
		}
		for(i=0;i<101;i++){
			if(f[i]>=q&&f[i]>max){
				max=f[i];
				ans=i;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}