cus = [int(i) for i in input().split(',')]
gru = [int(i) for i in input().split(',')]
x = int(input())
out = 0
for i in range(len(gru)-x+1):
    temp = 0
    for j in range(len(gru)):
        if(i<=j and j<=i+x-1):
            temp+=cus[j]*1
        else:temp+=cus[j]*gru[j]
    out = max(temp,out)
print(out)
7420541e268a77ea2bc39f63953b9a551cb93f16
<mask token>

<mask token>
for i in range(len(gru) - x + 1):
    temp = 0
    for j in range(len(gru)):
        if i <= j and j <= i + x - 1:
            temp += cus[j] * 1
        else:
            temp += cus[j] * gru[j]
    out = max(temp, out)
print(out)

cus = [int(i) for i in input().split(',')]
gru = [int(i) for i in input().split(',')]
x = int(input())
out = 0
for i in range(len(gru) - x + 1):
    temp = 0
    for j in range(len(gru)):
        if i <= j and j <= i + x - 1:
            temp += cus[j] * 1
        else:
            temp += cus[j] * gru[j]
    out = max(temp, out)
print(out)

cus = [int(i) for i in input().split(',')]
gru = [int(i) for i in input().split(',')]
x = int(input())
out = 0
for i in range(len(gru)-x+1):
    temp = 0
    for j in range(len(gru)):
        if(i<=j and j<=i+x-1):
            temp+=cus[j]*1
        else:temp+=cus[j]*gru[j]
    out = max(temp,out)
print(out)