#include <stdio.h>
#define N_MAX 50
#define DATE_MAX 100

int main(void)
{
    char free_members[DATE_MAX];
    int n, q, m, i, meeting_date, meeting_members;

    while(scanf("%d %d", &n, &q), n + q)
    {
        for(i = 0; i < DATE_MAX; i++)
            free_members[i] = 0;

        while(n--)
        {
            scanf("%d", &m);
            while(m--)
            {
                scanf("%d", &i);
                free_members[i]++;
            }
        }

        for(meeting_date = meeting_members = i = 0; i < DATE_MAX; i++)
            if(free_members[i] >= q && free_members[i] > meeting_members)
                meeting_date = i, meeting_members = free_members[i];

        printf("%d\n", meeting_date);
    }

    return 0;
}