#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
struct S{
  int b,c,d;
  S(){}
  S(int b,int c,int d):b(b),c(c),d(d){}
};
int a[300],n,m;
S b[300],e[301][301];
S fi(int p,int q){
  int i;
  if(e[p][q].b!=-1)
    return e[p][q];
  S mx=S(0,0,0);
  for(i=0;a[p]*i<=q;++i){
    S tm=fi(p+1,q-a[p]*i);
    if(mx.b<tm.b+b[p].b*i)
      mx.b=tm.b+b[p].b*i;
    if(mx.c<tm.c+b[p].c*i)
      mx.c=tm.c+b[p].c*i;
    if(mx.d<tm.d+b[p].d*i)
      mx.d=tm.d+b[p].d*i;
  }
  return e[p][q]=mx;
}
int main(){
  int i;
  //int n,m;
  while(cin>>n>>m){
    //int a[300];
    //S b[300];
    string s;
    for(i=0;i<n;++i){
      getline(cin,s);
      getline(cin,s);
      cin>>a[i]>>b[i].b>>b[i].c>>b[i].d;
    }
    fill(e[0],e[0]+301*301,S(-1,-1,-1));
    fill(e[n],e[n]+301,S(0,0,0));
    S mx=fi(0,m);
    cout<<max(max(mx.b,mx.c),mx.d)<<endl;
  }
  return 0;
}