#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define pb push_back #define eb emplace_back using ll=long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 50; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; ll p,q,r,a,b,c; void solve(){ cin>>p>>q>>r>>a>>b>>c; ll minv=max({p*(a-1)+1,q*(a+b-1)+1,r*(a+b+c-1)+1}); ll maxv=min({p*a,q*(a+b),r*(a+b+c)}); if(minv>maxv)cout<<-1<<"\n"; else cout<