#include <bits/stdc++.h>
using namespace std;
long long N, X, k;
long long gcd(long long a, long long b) {
  long long c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}
int main() {
  cin >> N >> X;
  k = gcd(N, X);
  cout << k << endl;
  cout << (N - k) * 3 << endl;
  return 0;
}
