n, m = map(int, input().split())
a, b, c = map(int, input().split())
max_weight = c * 1000
total_weight = n * a + m * b
eaten_n = 0
eaten_m = 0
if total_weight > max_weight:
while total_weight > max_weight:
if n > 0 and a >= b:
total_weight -= a
n -= 1
eaten_n += 1
elif m > 0:
total_weight -= b
m -= 1
eaten_m += 1
else:
break
print(eaten_n, eaten_m)
a, b, c = map(int, input().split())
max_weight = c * 1000
total_weight = n * a + m * b
eaten_n = 0
eaten_m = 0
if total_weight > max_weight:
while total_weight > max_weight:
if n > 0 and a >= b:
total_weight -= a
n -= 1
eaten_n += 1
elif m > 0:
total_weight -= b
m -= 1
eaten_m += 1
else:
break
print(eaten_n, eaten_m)