import itertools as it
def f():
p,r,b=[13,3,7.5],[17,5.5,2.5],[24,6,6]
l=[p]*3+[r]*2+[b]
o=[list(set(it.permutations(x))) for x in l]
mv,mb=1e9,0
for c in it.product(*o):
h=max(i[2] for i in c)
fs=[sorted(i[:2],reverse=True) for i in c]
for mw in range(int(max(f[0] for f in fs)),60):
x=y=lh=cw=0
for w,d in sorted(fs,key=lambda f:f[1],reverse=True):
if x+w>mw: y+=lh+1;x=lh=0
x+=w+1;lh=max(lh,d);cw=max(cw,x-1)
v=cw*(y+lh)*h
if v<mv: mv,mb=v,(cw,y+lh,h)
print(f"D:{mb} V:{mv}")
if __name__=="__main__":f()