A, B, C, D, N = map(int, input().split()) P, Q, R, S, T = map(int, input().split()) max_a = min(A, N) for a in range(max_a + 1): max_b = min(B, N - a) for b in range(max_b + 1): rem = N - a - b if rem < 0: continue if rem > C + D: continue time_rem = T - a * P - b * Q if time_rem < 0: continue if R != S: denominator = R - S numerator = time_rem - S * rem if denominator == 0: continue # この場合はR == Sでないと矛盾するためスキップ if numerator % denominator != 0: continue c = numerator // denominator d = rem - c if 0 <= c <= C and 0 <= d <= D: print(a, b, c, d) exit() else: # R == Sの場合、time_rem == R * rem でなければならない if time_rem != R * rem: continue # cは0<=c <=C、d=rem -c <=D → c >= rem -D c_min = max(0, rem - D) c_max = min(C, rem) if c_min > c_max: continue # 適当なcを選ぶ。例えば最大値 c = c_max d = rem - c if d >= 0 and d <= D: print(a, b, c, d) exit() else: # 最小のcを試す c = c_min d = rem - c if c >= 0 and c <= C and d >= 0 and d <= D: print(a, b, c, d) exit()