n,U,c[20],R[20],a,i;S(k,s,A,m,b){b=s<U;b&k<n&&S(k+1,s,A,m)+S(k+1,s+c[k],A|1<<k,m+1);for(i=n*!b;i--;)b|=A&1<<i&&A&R[i]^R[i];m<a*!b?a=m:0;}main(k,t){for(;scanf("%d%d",&n,&U)*n;S(0,0,0,0),printf("%d\n",a))for(a=i=n;i--;)for(R[i]=!scanf("%d%d",c+i,&k);k--;R[i]|=1<<n-1-t)scanf("%d",&t);}