/* 
   AOJ 1124
   When Can We Meet?
   2015.4.26
 */

#include<stdio.h>

int adjustment_of_schedule(int committee_num, int quorum)
{
  int i, j, target_date = 0, date, convenient_dates_num = 0, num_participant = 0, convenient_date[101] = {0};
  for(i = 0; i < committee_num; i++)
    {
      scanf("%d", &convenient_dates_num);
      for(j = 0 ; j < convenient_dates_num; j++)
	{
	  scanf("%d", &date);
	   convenient_date[date]++;
	}
    }

  for(i = 0; i < 101; i++)
    {
      if(convenient_date[i] >= quorum && convenient_date[i] > num_participant)
	{
	  target_date = i;
	  num_participant = convenient_date[i];
	}
    }

  return target_date;
}



int main(void)
{
  int n, q, date;
  while(1)
    {
      scanf("%d %d", &n, &q);
      if(n == 0 && q == 0)
	{
	  break;
	}

      date = adjustment_of_schedule(n, q);
      printf("%d\n", date);
    }
  return 0;
}