import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
public static void main
(String[] args
) { Scanner in
= new Scanner
(System.
in);
long m = in.nextLong();
long n = in.nextLong();
bi3 = bi1.gcd(bi2);
long g = bi3.longValue();
m /= g;
n /= g;
out.print((n + m - 2) + " ");
if (n % 2 == 0 & m % 2 != 0) out.print(4);
if (n % 2 != 0 & m % 2 != 0) out.print(3);
if (n % 2 != 0 & m % 2 == 0) out.print(2);
out.flush();
}
}
aW1wb3J0IGphdmEuaW8uKjsKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5tYXRoLio7CgpwdWJsaWMgY2xhc3MgTWFpbiB7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CgkJU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkJUHJpbnRXcml0ZXIgb3V0ID0gbmV3IFByaW50V3JpdGVyKFN5c3RlbS5vdXQpOwoJCQoJCWxvbmcgbSA9IGluLm5leHRMb25nKCk7CgkJbG9uZyBuID0gaW4ubmV4dExvbmcoKTsKCQlCaWdJbnRlZ2VyIGJpMSwgYmkyLCBiaTM7CgkJYmkxID0gQmlnSW50ZWdlci52YWx1ZU9mKG0pOwoJCWJpMiA9IEJpZ0ludGVnZXIudmFsdWVPZihuKTsKCQliaTMgPSBiaTEuZ2NkKGJpMik7CgkJbG9uZyBnID0gYmkzLmxvbmdWYWx1ZSgpOwoJCW0gLz0gZzsKCQluIC89IGc7CgkJb3V0LnByaW50KChuICsgbSAtIDIpICsgIiAiKTsKCQlpZiAobiAlIDIgPT0gMCAmIG0gJSAyICE9IDApIG91dC5wcmludCg0KTsKCQlpZiAobiAlIDIgIT0gMCAmIG0gJSAyICE9IDApIG91dC5wcmludCgzKTsKCQlpZiAobiAlIDIgIT0gMCAmIG0gJSAyID09IDApIG91dC5wcmludCgyKTsKCQkKCQlvdXQuZmx1c2goKTsKCX0KfQ==