n,m,k,*x=list(map(int,open(0).read().split()))

s=sum(x[:n])

z=i=j=n

while~i:

	while j<n+m and s+x[j]<=k:s+=x[j];j+=1

	if s<=k:z=max(z,i+j)

	i-=1

	s-=x[i]

print((z-n))
n,m,k,*x=list(map(int,open(0).read().split()))

s=sum(x[:n])

z=i=j=n

x+=k,

while~i:

	while s+x[j]<=k:s+=x[j];j+=1

	if s<=k:z=max(z,i+j)

	i-=1

	s-=x[i]

print((z-n))
n, m, k, *x = list(map(int, open(0).read().split()))
s = sum(x[:n])
z = i = j = n
while ~i:
    while j < n + m and s + x[j] <= k:
        s += x[j]
        j += 1
    if s <= k:
        z = max(z, i + j)
    i -= 1
    s -= x[i]
print((z - n))

n, m, k, *x = list(map(int, open(0).read().split()))
s = sum(x[:n])
z = i = j = n
x += (k,)
while ~i:
    while s + x[j] <= k:
        s += x[j]
        j += 1
    if s <= k:
        z = max(z, i + j)
    i -= 1
    s -= x[i]
print((z - n))

+x += (k,) -    while j < n + m and s + x[j] <= k: +    while s + x[j] <= k: