#include<bits/stdc++.h>
using namespace std;

int main(){

    int n, m;

    while(cin >> n >> m){
        vector<int> c(n);
        vector<int> v(n);
        vector<int> d(n);
        vector<int> l(n);

        for(int i = 0; i < n; i++){
            
            string s;
            cin.ignore();
            getline(cin, s);
            //cout << "ok" << endl;
            // cin >> c[i] >> v[i] >> d[i] >> l[i];
            scanf("%d %d %d %d", &c[i], &v[i], &d[i], &l[i]);
        }

        int ans = 0;
        vector<vector<int> > dp(n + 1, vector<int> (m + 1, 0));
        
        for(int i = 0; i < n; i++){
            for(int j = 0; j <= m; j++){
                int value = 0;

                for(int k = j; k <= m; k += c[i]){
                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + value);
                    value += v[i];
                }
            }
        }

        for(int j = 0; j <= m; j++){
            ans = max(ans, dp[n][j]);
        }

        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= m; j++){
                dp[i][j] = 0;
            }
        }


        for(int i = 0; i < n; i++){
            for(int j = 0; j <= m; j++){
                int value = 0;

                for(int k = j; k <= m; k += c[i]){
                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + value);
                    value += d[i];
                }
            }
        }

        for(int j = 0; j <= m; j++){
            ans = max(ans, dp[n][j]);
        }
        

        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= m; j++){
                dp[i][j] = 0;
            }
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j <= m; j++){
                int value = 0;

                for(int k = j; k <= m; k += c[i]){
                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + value);
                    value += l[i];
                }
            }
        }

        for(int j = 0; j <= m; j++){
            ans = max(ans, dp[n][j]);
        }

        cout << ans << endl;
    }
}
