#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); ll P,Q,R,A,B,C; cin >> P >> Q >> R >> A >> B >> C; auto f = [&](ll N) { int ok = 1; ok &= (N + P - 1) / P <= A; ok &= (N + Q - 1) / Q <= A + B; ok &= (N + R - 1) / R <= A + B + C; return ok; }; ll ok = 0, ng = 1e18; while(ng - ok > 1) { ll mid = (ok + ng) / 2; (f(mid) ? ok : ng) = mid; } ll r = ok; auto g = [&](ll N) { int ok = 1; ok &= A <= (N + P - 1) / P; ok &= A + B <= (N + Q - 1) / Q; ok &= A + B + C <= (N + R - 1) / R; return ok; }; ok = 0, ng = 1e18; while(ng - ok > 1) { ll mid = (ok + ng) / 2; (g(mid) ? ng : ok) = mid; } ll l = ng; auto h = [&](ll N) { int ok = 1; ok &= A == (N + P - 1) / P; ok &= A + B == (N + Q - 1) / Q; ok &= A + B + C == (N + R - 1) / R; return ok; }; if(h(l) && h(r)) { cout << l << " " << r << endl; } else if(h(l)) { cout << l << endl; } else { cout << -1 << endl; } }