#include <iostream>
#include <algorithm>
using namespace std;
int main() {
long m, n;
cin >> m >> n;
long g = __gcd(m, n);
m /= g;
n /= g;
cout << (n + m - 2) << " ";
if (n % 2 == 0 and m % 2 != 0) cout << 4;
if (n % 2 != 0 and m % 2 != 0) cout << 3;
if (n % 2 != 0 and m % 2 == 0) cout << 2;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cglsb25nIG0sIG47CgljaW4gPj4gbSA+PiBuOwoJbG9uZyBnID0gX19nY2QobSwgbik7CgltIC89IGc7CgluIC89IGc7Cgljb3V0IDw8IChuICsgbSAtIDIpIDw8ICIgIjsKCWlmIChuICUgMiA9PSAwIGFuZCBtICUgMiAhPSAwKSBjb3V0IDw8IDQ7CglpZiAobiAlIDIgIT0gMCBhbmQgbSAlIDIgIT0gMCkgY291dCA8PCAzOwoJaWYgKG4gJSAyICE9IDAgYW5kIG0gJSAyID09IDApIGNvdXQgPDwgMjsKCXJldHVybiAwOwp9