#include <bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;
const int maxn = 1e6+7;
ll n,k,ans=LLONG_MIN,pre[maxn],a,b;
vector<ll> uoc;
void sanguoc()
{
    for (int i=1;i*i<=b;i++)
    {
        if (b % i == 0)
        {
            uoc.push_back(i);
            if (b/i != i) uoc.push_back(b/i);
        }
    }
}
ll lcm(ll x, ll y)
{
    return x / __gcd(x,y) * y;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    freopen("HOCTOAN.INP","r",stdin);
    freopen("HOCTOAN.OUT","w",stdout);
    cin >> a >> b;
    sanguoc();
    sort(uoc.begin(),uoc.end());
    ll ma = LLONG_MAX,ans1=-1,ans2=-1,miX=LLONG_MAX;
    for (auto x:uoc)
    {
        for (auto y:uoc)
        {
            if (__gcd(x,y) == a && lcm(x,y) == b)
            {
                ll sum = x+y;
                if (sum < ma)
                {
                    ma = sum;
                    miX = x;
                    ans1 = x;
                    ans2 = y;
                }
                else if (sum == ma)
                {
                    if (x < miX)
                    {
                        miX = x;
                        ans1 = x;
                        ans2 = y;
                    }
                }
            }
        }
    }
    if (ans1 != -1 && ans2 != -1) cout << ma << '\n' << ans1 << ' ' << ans2;
    else cout << -1;
    return 0;
}
