← Home
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int t;
    cin >> t;
 
    while (t--)
    {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
 
        ll ab = a * b;
 
        vector<ll> da, db;
 
        for (ll i = 1; i * i <= a; i++)
        {
            if (a % i == 0)
            {
                da.push_back(i);
                if (i * i != a)
                    da.push_back(a / i);
            }
        }
 
        for (ll i = 1; i * i <= b; i++)
        {
            if (b % i == 0)
            {
                db.push_back(i);
                if (i * i != b)
                    db.push_back(b / i);
            }
        }
 
        bool found = false;
 
        for (ll x1 : da)
        {
            for (ll x2 : db)
            {
                ll g = x1 * x2;
 
                ll x = ((a + g + 1 - 1) / g) * g;
                if (x > c)
                    continue;
 
                ll s = ab / g;
                ll y = ((b + 1 + s - 1) / s) * s;
 
                if (y <= d)
                {
                    cout << x << " " << y << "\n";
                    found = true;
                    break;
                }
            }
            if (found)
                break;
        }
 
        if (!found)
            cout << "-1 -1\n";
    }
}