#include <iostream>
#include<stdio.h>
int c[105][105];
int b[105][105];
int dp[10005];
int dpa[10005];
int main()
{
int n, m, x,ans;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i )
{
scanf("%d", &c[i][0]);
for (int j = 1; j <= c[i][0]; j )
{
scanf("%d", &x);
c[i][j] = x;
if (j > 1)c[i][j] = c[i][j - 1];
}
}
for (int i = 0; i < n; i )
{
int zs = c[i][0];
for (int j = 1; j <= zs; j )
{
for (int z = 0; z <= j; z )
{
int y = j - z;
if(z!=0)ans = c[i][z] c[i][zs] - c[i][zs - y];
else ans = c[i][zs] - c[i][zs - y];
b[i][j] = b[i][j] > ans ? b[i][j] : ans;
}
}
}
for (int i = 0; i < n; i )
{
ans = 0;
for (int j = 0; j <= m; j )
{
for (int bc = 0; bc <= j; bc )
{
int temp = dp[j-bc] b[i][bc];
if (temp > ans)ans = temp;
}
dpa[j] = ans;
}
for (int j = 1; j <= m; j )dp[j] = dpa[j];
}
ans = 0;
for (int i = 0; i <= m; i )ans = ans > dp[i] ? ans : dp[i];
printf("%dn", ans);
}