#include #define PI 3.14159265359 using namespace std; int main() { int64_t P, Q, R, A, B, C; cin >> P >> Q >> R >> A >> B >> C; int64_t N = 0; int f = 0; int64_t n = P * (A - 1) + 1, m = P * (A + 1) - 1; //cout << "n:" << n << ' ' << "m:" << m << endl; int64_t min = -1, max = -1; for (int64_t i = n; i <= m; i++) { int64_t x = i % Q; if (x) { x = i / Q; x++; } else { x = i / Q; } //cout << "x:" << x << endl; x -= A; if (x == B) { int64_t y = i % R; if (y) { y = i / R; y++; } else { y = i / R; } y -= (A + B); if (y == C) { if (!f) { min = i; f = 1; } else { max = i; } //cout << "push" << endl; } } else { continue; } } if (!f) { cout << -1 << endl; return 0; } else { cout << min << ' ' << max << endl; } }