include [HTML_REMOVED]
using namespace std;
const int N = 105;
int w[N], v[N][N], s[N][N], f[N], n, m, i, k, j;
int main()
{
cin >> n >> m;
for (i = 0; i < n; i)
{
cin >> w[i];
for (j = 0; j < w[i]; j)
cin >> v[i][j] >> s[i][j];
}
for (i = 0; i < n; i)
for(k = m; k >= 0; –k)
for (j = 0; j < w[i]; j)
if(k >= v[i][j]) f[k] = max(f[k], f[k - v[i][j]] + s[i][j]);
cout << f[m] << endl;
return 0;
}