#include<stdio.h>

int main()
{
    int day,up;
    scanf("%d%d",&day,&up);
    int ans=0;
    int temp=up;
    bool flag=0;
    for(int i=0;i<day;++i)
    {
        int house,need,cost=0;
        scanf("%d",&house);
        for(int j=0;j<house;++j)
        {
            scanf("%d",&need);
            cost+=need;
        }
        if(temp-cost<0 && flag!=1)
        {
            flag = 1;
            ans = i+1;
        }
        else
        {
            temp-=cost;
        }
        temp+=up;
    }
    if(flag)
        printf("%d\n",ans);
    else
        printf("-1\n");
}
