#include <stdio.h>

int main(void)
{
    while(1){
        int N, Q;
        scanf("%d %d", &N, &Q);
        if(N == 0 && Q == 0)
            break;

        int i;
        int days[101] = {0};
        for(i = 0; i < N; i++){
            int M;
            scanf("%d", &M);
            int j;
            for(j = 0; j < M; j++){
                int day;
                scanf("%d", &day);
                days[day]++;
            }
        }
        int max_d = 0;
        int max_p = 0;
        for(i = 1; i <= 100; i++){
            if(days[i] >= Q && max_p < days[i]){
                max_d = i;
                max_p = days[i];
            }
        }

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

    return 0;
}