#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 2e5 + 5;
const long long MAX = 1e18;
template <typename T>
T gcd(T x, T y) {
  return y == 0 ? x : gcd(y, x % y);
}
template <typename T>
T lcm(const T &a, const T &b) {
  return (a * b) / gcd(a, b);
}
void vcout(vector<long long> &v) {
  long long i;
  for (i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
void vpcout(vector<pair<long long, long long> > &v) {
  long long i;
  for (i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
}
void acout(long long *a, long long n) {
  long long i;
  for (i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
long long kpow(long long a, long long b) {
  long long ct = 0;
  long long k = 1;
  while (ct < b) {
    k *= a;
    ct++;
  }
  return k;
}
int pows(int a, int b, int mod) {
  int ans = 1;
  while (b) {
    if (b & 1) {
      ans = (1LL * (ans)*a) % mod;
    }
    a = (1LL * a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long klog(long long x, long long b) {
  long long ct = 0;
  long long k = 1;
  while (k <= x) {
    k *= b;
    ct++;
  }
  return ct - 1;
}
void freq(long long *a, long long n, vector<long long> &fre) {
  long long i;
  for (i = 0; i < n; i++) {
    fre[a[i]]++;
  }
}
template <typename T>
void pfact(vector<pair<T, T> > &v, T k) {
  T i;
  for (i = 2; i <= sqrt(k); i++)
    if (k % i == 0) {
      T x = 0;
      while (k % i == 0) {
        k /= i;
        x++;
      }
      v.push_back(make_pair(i, x));
    }
  if (k != 1) {
    v.push_back(make_pair(k, 1));
  }
}
void sieve(long long *spf) {
  spf[1] = 1;
  for (int i = 2; i < N; i++) spf[i] = i;
  for (int i = 4; i < N; i += 2) spf[i] = 2;
  for (int i = 3; i * i < N; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < N; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
vector<int> getFactorization(int x, int *spf) {
  vector<int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
bool sortcol(const vector<long long> &v1, const vector<long long> &v2) {
  return v1[0] < v2[0];
}
int dp[101][10006];
int dp1[101][10006];
int main() {
  long long i, j, n, l, m;
  for (i = 0; i < 101; i++) {
    for (j = 0; j < 101; j++) {
      dp[i][j] = 0;
    }
  }
  cin >> n >> m;
  vector<int> a[n];
  vector<int> siz;
  for (i = 0; i < n; i++) {
    int s;
    cin >> s;
    siz.push_back(s);
    int sum = 0;
    a[i].push_back(0);
    for (j = 0; j < s; j++) {
      int x;
      cin >> x;
      sum += x;
      a[i].push_back(sum);
    }
    for (j = 1; j < s + 1; j++) {
      for (l = j; l < s + 1; l++) {
        dp[i][s - l + j - 1] =
            max(a[i][s] - (a[i][l] - a[i][j - 1]), dp[i][s - l + j - 1]);
      }
    }
    dp[i][s] = a[i][s];
    for (j = s + 1; j < 10005; j++) {
      dp[i][j] = dp[i][j - 1];
    }
  }
  for (j = 0; j < 10005; j++) {
    dp1[0][j] = 0;
  }
  for (i = 1; i < n + 1; i++) {
    for (j = 0; j < m + 1; j++) {
      for (l = 0; l < min(siz[i - 1] + 1, (int)(j + 1)); l++) {
        dp1[i][j] = max(dp1[i - 1][j - l] + dp[i - 1][l], dp1[i][j]);
      }
    }
  }
  int ma = 0;
  for (i = 0; i < m + 1; i++) {
    ma = max(ma, dp1[n][i]);
  }
  cout << ma << endl;
}
