Buggy python submission (verdict: Runtime Error):
while(1):
    try:
        N,M=map( int,raw_input().split())
        W=[[] for i in range(3)]
        for i in range(N):
            name=raw_input()
            inp=map( int,raw_input().split())
            c=inp[0]
            for i in range(3):
                W[i].append([c, inp[1+i]])

        ans=0
        for i in range(3):
            DP=[[0 for x in range(M+1)] for y in range(N)]

            for t in range(M):
                ci=W[i][0][0]*t
                if ci <= M:
                    DP[0][ci]=W[i][0][1]*t
                else:
                    break

            for y in range(1,N):
                for x in range(M+1):

                    for t in range(M):
                        ci=W[i][y][0]*t
                        if ci <= x:
                            DP[y][x] = max(DP[y][x], DP[y-1][x-ci]+W[i][y][1]*t )
                        else:
                            break
            ans=max(ans, max(DP[-1]))
        print ans
    except:
        break



Fixed submission:
while(1):
    try:
        N,M=map( int,raw_input().split())
        W=[[] for i in range(3)]
        for i in range(N):
            name=raw_input()
            inp=map( int,raw_input().split())
            c=inp[0]
            for i in range(3):
                W[i].append([c, inp[1+i]])
        for i in range(3):
            W[i].sort(key = lambda x:x[0])
        ans=0
        for i in range(3):
            U=[0 for x in range(M+1)]
            V=[0 for x in range(M+1)]
            for y in range(N):
                for t in range(M+1):
                    ci=W[i][y][0]*t
                    if ci <= M:
                        U[ci]=max(U[ci], W[i][y][1]*t)
                    else:
                        break
            for j in range(M+1):
                for k in range(j+1):
                    V[j]=max(V[j], V[j-k]+U[k])
            ans=max(ans, V[-1])
        print ans
    except:
        break

Buggy python submission (verdict: Runtime Error):
while(1):
    try:
        N,M=map( int,raw_input().split())
        W=[[] for i in range(3)]
        for i in range(N):
            name=raw_input()
            inp=map( int,raw_input().split())
            c=inp[0]
            for i in range(3):
                W[i].append([c, inp[1+i]])
        for i in range(3):
            W[i].sort(key = lambda x:x[0])
        ans=0
        for i in range(3):
            DP=[[0 for x in range(M+1)] for y in range(N)]

            for t in range(M+1):
                ci=W[i][0][0]*t
                if ci <= M:
                    DP[0][ci]=W[i][0][1]*t
                else:
                    break

            for y in range(1,N):
                for x in range(M+1):
                    for t in range(M):
                        ci=W[i][y][0]*t
                        if ci <= x:
                            DP[y][x] = max(DP[y][x], DP[y-1][x-ci]+W[i][y][1]*t )
                        else:
                            break
            ans=max(ans, max(DP[-1]))
        print ans
    except:
        break



Fixed submission:
while(1):
    try:
        N,M=map( int,raw_input().split())
        W=[[] for i in range(3)]
        for i in range(N):
            name=raw_input()
            inp=map( int,raw_input().split())
            c=inp[0]
            for i in range(3):
                W[i].append([c, inp[1+i]])
        for i in range(3):
            W[i].sort(key = lambda x:x[0])
        ans=0
        for i in range(3):
            U=[0 for x in range(M+1)]
            V=[0 for x in range(M+1)]
            for y in range(N):
                for t in range(M+1):
                    ci=W[i][y][0]*t
                    if ci <= M:
                        U[ci]=max(U[ci], W[i][y][1]*t)
                    else:
                        break
            for j in range(M+1):
                for k in range(j+1):
                    V[j]=max(V[j], V[j-k]+U[k])
            ans=max(ans, V[-1])
        print ans
    except:
        break