#include using namespace std; using ll = long long; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int t, n; vector a(4), b(4); cin >> a >> n >> b >> t; const int d = b[2] - b[3]; for(int i = 0; i <= n && i <= a[0] && i * b[0] <= t; i++){ for(int j = 0; i + j <= n && j <= a[1] && i * b[0] + j * b[1] <= t; j++){ const int rt = t - (i * b[0] + j * b[1]); const int r = n - (i + j); // Ax + B * (r - x) = rt // (A - B) * x + B * r == rt int rhs = rt - b[3] * r; if(rhs == 0 && r <= a[3]){ cout << i << " " << j << " " << 0 << " " << r << '\n'; return 0; } if(d == 0){ int c2 = min(a[2], r), c3 = r - c2; if(b[2] * (c2 + c3) == rt && c3 <= a[3]){ cout << i << " " << j << " " << c2 << " " << c3 << '\n'; return 0; } }else{ int c2 = rhs / d, c3 = r - c2; if(c2 * d == rhs && 0 <= c2 && c2 <= a[2] && 0 <= c3 && c3 <= a[3]){ cout << i << " " << j << " " << c2 << " " << c3 << '\n'; return 0; } } } } }