#include using namespace std; int main() { long long P, Q, R, A, B, C; cin >> P >> Q >> R >> A >> B >> C; long long npmax = A * P; long long nqmax = (B + A) * Q; long long nrmax = (C + B + A) * R; long long ma = min( npmax, min( nqmax, nrmax ) ); long long mi = INT64_MAX; long long n = ma; while( true ) { long long a = (n + P - 1) / P; long long b = (n + Q - 1) / Q - a; long long c = (n + R - 1) / R - a - b; if( a != A || b != B || c != C ) break; mi = n; n--; } if( mi == INT64_MAX ) cout << -1 << endl; else cout << mi << " " << ma << endl; }