#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,q;
	while(cin>>n>>q,n) 
	{
		int dates[101];
		fill(dates,dates+101,0);

		for(int i = 0; i < n; ++i)
		{
			int m; cin>>m;
			for(int j = 0; j < m; ++j)
			{
				int tmp; cin>>tmp;
				dates[tmp]++;
			}
		}

		int mx=0,ans=0;
		for(int i = 0; i < 101; ++i)
		{
			if(q<=dates[i]&&mx<dates[i])
			{
				mx=dates[i];
				ans=i;
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}