#include <bits/stdc++.h>
using namespace std;
int n, M, m[10100], f[10100][110], a[10100], ans = 0;
int sum[10100], p1[20100], p2[20100], p[20010];
int main() {
  cin >> n >> M;
  for (int k = 1; k <= n; ++k) {
    cin >> m[k];
    for (int i = 1; i <= m[k]; ++i) cin >> a[i], a[i] += a[i - 1];
    f[k][0] = 0;
    for (int i = 0; i <= m[k]; ++i) {
      for (int j = 0; j + i <= m[k]; ++j)
        f[k][m[k] - i] = max(a[m[k]] - (a[j + i] - a[j]), f[k][m[k] - i]);
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = M; j >= 1; --j)
      for (int k = 1; k <= min(j, m[i]); ++k)
        p[j] = max(p[j - k] + f[i][k], p[j]);
  printf("%d\n", p[M]);
}
