#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
ostream &operator<<(ostream &out, pair<T, T1> obj) {
  out << "(" << obj.first << "," << obj.second << ")";
  return out;
}
template <typename T, typename T1>
ostream &operator<<(ostream &out, map<T, T1> cont) {
  typename map<T, T1>::const_iterator itr = cont.begin();
  typename map<T, T1>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, set<T> cont) {
  typename set<T>::const_iterator itr = cont.begin();
  typename set<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, multiset<T> cont) {
  typename multiset<T>::const_iterator itr = cont.begin();
  typename multiset<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T,
          template <typename ELEM, typename ALLOC = allocator<ELEM>> class CONT>
ostream &operator<<(ostream &out, CONT<T> cont) {
  typename CONT<T>::const_iterator itr = cont.begin();
  typename CONT<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
  return out;
}
template <typename T, unsigned int N, typename CTy, typename CTr>
typename enable_if<!is_same<T, char>::value, basic_ostream<CTy, CTr> &>::type
operator<<(basic_ostream<CTy, CTr> &out, const T (&arr)[N]) {
  for (auto i = 0; i < N; ++i) out << arr[i] << " ";
  out << endl;
  return out;
}
template <typename T>
T gcd(T a, T b) {
  T min_v = min(a, b);
  T max_v = max(a, b);
  while (min_v) {
    T temp = max_v % min_v;
    max_v = min_v;
    min_v = temp;
  }
  return max_v;
}
template <typename T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
template <typename T>
T fast_exp_pow(T base, T exp, T mod) {
  long long res = 1;
  while (exp) {
    if (exp & 1) {
      res *= base;
      res %= mod;
    }
    exp >>= 1;
    base *= base;
    base %= mod;
  }
  return res % mod;
}
int N, M, answer;
int numbers[110][10000], length[110], dp_max[110][10000];
int dp_sum_l[110][10000], dp_sum_r[110][10000], memo[110][10000];
int solve(int ind, int val) {
  if (val == M) return 0;
  if (ind == N) {
    if (M - val <= 0) return -9999999;
    return dp_max[ind][M - val];
  }
  int &ret = memo[ind][val];
  if (ret != -1) return ret;
  ret = 0;
  for (auto i = 0; i <= length[ind]; ++i) {
    if (val + i > M) break;
    ret = max(ret, solve(ind + 1, val + i) + dp_max[ind][i]);
  }
  return ret;
}
int main() {
  scanf("%d%d", &N, &M);
  for (auto i = 1; i <= N; ++i) {
    scanf("%d", length + i);
    for (auto j = 1; j <= length[i]; ++j) scanf("%d", &numbers[i][j]);
  }
  for (auto i = 1; i <= N; ++i) {
    for (auto j = 1; j <= length[i]; ++j)
      dp_sum_l[i][j] = dp_sum_l[i][j - 1] + numbers[i][j];
    for (auto j = 1; j <= length[i]; ++j)
      dp_sum_r[i][j] = dp_sum_r[i][j - 1] + numbers[i][length[i] - j + 1];
    for (auto j = 0; j <= length[i]; ++j) {
      for (auto k = 0; k <= length[i]; ++k) {
        if (j + k > length[i]) continue;
        dp_max[i][j + k] =
            max(dp_max[i][j + k], dp_sum_l[i][j] + dp_sum_r[i][k]);
      }
    }
  }
  memset(memo, -1, sizeof(memo));
  for (auto i = 0; i <= length[1]; ++i) {
    if (i > M) break;
    answer = max(answer, solve(2, i) + dp_max[1][i]);
  }
  printf("%d\n", answer);
  return 0;
}
