#include using namespace std; int main() { int A, B, C, D, N; cin >> A >> B >> C >> D >> N; int P, Q, R, S, T; cin >> P >> Q >> R >> S >> T; for (int a = 0; a <= A; a++) { for (int b = 0; b <= B; b++) { int rem_n = N - a - b; int rem_t = T - a * P - b * Q; // c + d = rem_n // cR + dS = rem_t if (R == S) { if (rem_n * R != rem_t) { continue; } else { if (C + D < rem_n) { continue; } else { int nc = min(C, rem_n); cout << a << " " << b << " " << nc << " " << rem_n - nc << endl; return 0; } } } else if (R < S) { if ((rem_n * S - rem_t) % (S - R) != 0) { continue; } int c = (rem_n * S - rem_t) / (S - R); int d = rem_n - c; if (c >= 0 && c <= C && d >= 0 && d <= D) { cout << a << " " << b << " " << c << " " << d << endl; return 0; } } else { if ((rem_t - rem_n * S) % (R - S) != 0) { continue; } int c = (rem_t - rem_n * S) / (R - S); int d = rem_n - c; if (c >= 0 && c <= C && d >= 0 && d <= D) { cout << a << " " << b << " " << c << " " << d << endl; return 0; } } } } }