#include <bits/stdc++.h>
using namespace std;

#define pb         push_back

const int INF = 100000000;

int main(void) {
	while(1){
		int n, q;
		vector<int> sche(200, 0);
		cin >> n >> q;
		if(n == 0 && q == 0) break;

		for(int i=0; i<n; i++){
			int m;
			cin >> m;
			for(int j=0; j<m; j++){
				int date;
				cin >> date;
				sche[date]++;
			}
		}
		int i;
		int ma = INT_MIN;
		int early = 0;
		for(i=0; i<=100; i++){
			if(sche[i] > ma && sche[i] >= q){
				ma = sche[i];
				early = i;
			}
		}

		cout << early << endl;
	}
	
	return 0;
}