#include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; bitset<200000001> b; int main() { FAST_IO auto ans = 0LL; vector> a(4); for (auto& [x, y] : a) cin >> x; i64 N; cin >> N; for (auto& [x, y] : a) cin >> y; i64 T; cin >> T; for (int i = 0; i <= a[0].first; i ++) { for (int j = 0; j <= a[1].first; j ++) { auto x = i * a[0].second + j * a[1].second; b[x] = true; } } for (int i = 0; i <= a[2].first; i ++) { for (int j = 0; j <= a[3].first; j ++) { auto x = i * a[2].second + j * a[3].second; auto y = T - x; if (b[y]) { for (int i2 = 0; i2 < a[0].first; i2 ++) { for (int j2 = 0; j2 < a[1].first; j2 ++) { if (x + i2 * a[0].second + j2 * a[1].second == T) { cout << i2 << " " << j2 << " " << i << " " << j << endl; return 0; } } } } } } cout << -1 << endl; }