#include <bits/stdc++.h>
using namespace std;
long long power(long long b, long long p) {
  if (b == 0) return 0;
  long long res = 1;
  while (p) {
    if (p % 2) {
      res = (res * b) % 1000000007;
      p--;
    } else {
      b = (b * b) % 1000000007;
      p /= 2;
    }
  }
  return res;
}
long long Root(long long r, vector<long long> &root) {
  while (root[r] != r) {
    root[r] = root[root[r]];
    r = root[r];
  }
  return r;
}
void EE(long long a, long long b, long long &x, long long &y) {
  long long t;
  if (b == 0) {
    y = 0, x = 1;
    return;
  }
  EE(b, a % b, x, y);
  t = x;
  x = y;
  y = t - a / b * y;
}
void build(long long node, long long start, long long end, vector<long long> &a,
           vector<long long> &tree) {
  if (start == end) {
    tree[node] = a[start];
    return;
  }
  long long mid = (start + end) / 2;
  build(2 * node, start, mid, a, tree);
  build(2 * node + 1, mid + 1, end, a, tree);
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
long long query(long long node, long long start, long long end, long long l,
                long long r, vector<long long> &tree, vector<long long> &lazy) {
  if (lazy[node]) {
    tree[node] = end - start + 1 - tree[node];
    if (start != end) {
      lazy[2 * node] = lazy[2 * node] ^ 1;
      lazy[2 * node + 1] = lazy[2 * node + 1] ^ 1;
    }
    lazy[node] = 0;
  }
  if (start >= l && end <= r) {
    return tree[node];
  }
  if (l > end || r < start) return 0;
  long long mid = (start + end) / 2;
  return query(2 * node, start, mid, l, r, tree, lazy) +
         query(2 * node + 1, mid + 1, end, l, r, tree, lazy);
}
void update(long long node, long long start, long long end, long long l,
            long long r, vector<long long> &tree, vector<long long> &lazy) {
  if (lazy[node]) {
    tree[node] = end - start + 1 - tree[node];
    if (start != end) {
      lazy[2 * node] = lazy[2 * node] ^ 1;
      lazy[2 * node + 1] = lazy[2 * node + 1] ^ 1;
    }
    lazy[node] = 0;
  }
  if (l > end || r < start) return;
  if (start >= l && end <= r) {
    tree[node] = end - start + 1 - tree[node];
    if (start != end) {
      lazy[2 * node] = lazy[2 * node] ^ 1;
      lazy[2 * node + 1] = lazy[2 * node + 1] ^ 1;
    }
    return;
  }
  long long mid = (start + end) / 2;
  update(2 * node, start, mid, l, r, tree, lazy);
  update(2 * node + 1, mid + 1, end, l, r, tree, lazy);
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
vector<vector<long long> > mm(vector<vector<long long> > &a,
                              vector<vector<long long> > &b) {
  long long r, c1, c2, i, j, k;
  r = a.size();
  c1 = b.size();
  c2 = b[0].size();
  vector<vector<long long> > res(r, vector<long long>(c2));
  for (j = 0; j < r; j++) {
    for (k = 0; k < c2; k++) {
      for (i = 0; i < c1; i++) {
        res[j][k] = (res[j][k] + a[j][i] * b[i][k]) % 1000000007;
      }
    }
  }
  return res;
}
vector<vector<long long> > exp(vector<vector<long long> > &M, long long power) {
  long long m = M.size();
  vector<vector<long long> > id(m, vector<long long>(m));
  long long i, j;
  for (i = 0; i < m; i++) id[i][i] = 1;
  while (power > 0) {
    if (power % 2) id = mm(id, M);
    M = mm(M, M);
    power /= 2;
  }
  return id;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  long long n, m, i, j, k, x, size;
  cin >> n >> m;
  vector<vector<long long> > dp1(n + 1, vector<long long>(101)),
      dp2(n + 1, vector<long long>(m + 1)), p(n + 1);
  for (i = 1; i <= n; i++) {
    cin >> size;
    p[i].push_back(0);
    for (j = 0; j < size; j++) {
      cin >> x;
      p[i].push_back(x);
      p[i][j + 1] += p[i][j];
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j < p[i].size(); j++) {
      for (k = 0; k <= j; k++)
        dp1[i][j] = max(dp1[i][j], p[i][k] + p[i][p[i].size() - 1] -
                                       p[i][p[i].size() - 1 - (j - k)]);
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      for (k = 0; k < min((long long)p[i].size(), j + 1); k++) {
        dp2[i][j] = max(dp2[i][j], dp2[i - 1][j - k] + dp1[i][k]);
      }
    }
  }
  cout << dp2[n][m];
}
