#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef struct a {
int time[1000];
int joy[1000];
}fin;
int main()
{
int N, T, n;
fin x;
int all;
int i, j;
int aa[101][2002] = { {0} };//aa则为在背包还有j容积时,前i个数所可容纳的最大愉悦度
while (1) {
all = 0;
j = 0;
i = 0;
scanf("%d %d", &N, &T);
if (N == 0 && T == 0)
break;
for (; j <= N - 1; j++) {
scanf("%d", &n);
all += n;
for (i = all - n; i <= all - 1; i++)
{
scanf("%d", &x.joy[i]);
}for (i = all - n; i <= all - 1; i++)
{
scanf("%d", &x.time[i]);
}
}
for (i = 1; i <= all ; i++)//i为前i个数
{
for (j = 1; j <= T; j++)//j为此时所剩的时间
{
if (x.time[i-1] > j)
aa[i][j] = aa[i - 1][j];
else {
if (aa[i - 1][j] > aa[i - 1][j - x.time[i-1]] + x.joy[i-1])//比较,此时容纳第i个数是否为最优解
aa[i][j] = aa[i - 1][j];
else aa[i][j] = aa[i - 1][j - x.time[i-1]] + x.joy[i-1];
}
}
}printf("%d\n", aa[all][T]);
}
return 0;
}//经典的背包问题