#include #include #include #include #include #include #include #include #include #include #include using namespace std; using int64 = long long; bool ng(int64 p, int64 a, int64 n, int64 m) { // cerr << p << " " << a << " " << n << " " << m << " " << (n+p-1)/p - m << endl; return (n+p-1)/p - m != a; } int main() { int64 p,q,r,a,b,c; cin >> p >> q >> r >> a >> b >> c; int64 _max = min({p*a, q*(b+a), r*(c+a+b)}); cerr << p*a << " " << q*(b+a) << " " << r*(c+a+b) << endl; int64 _min = _max - min({p-1, q-1, r-1}); cerr << (_min) << endl; cerr << (_max) << endl; if (ng(p,a,_max,0) || ng(q,b,_max,a) || ng(r,c,_max,a+b)) { cout << -1 << endl; return 0; } if (ng(p,a,_min,0) || ng(q,b,_min,a) || ng(r,c,_min,a+b)) { cout << -1 << endl; return 0; } cout << _min << " " << _max << endl; }