# 変形してQ*(M+N) = N*M*P # gcd(P, Q)で両辺を割る # もしP=Q=1の場合、M=N=2 # それ以外の場合、N,MはQの素因数を持つ、N+MはPの倍数 # Qの約数でNを全探索すればいい def divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] from math import gcd P, Q = map(int, input().split()) g = gcd(P, Q) P = P//g Q = Q//g if P == 1: print(1) print(Q*2, Q*2) else: ans_list = [] divs = divisors(Q) for n in divs: if (P*n-Q) != 0 and (n*Q)%(P*n-Q) == 0 and (n*Q)//(P*n-Q) > 0: if Q*(((n*Q)//(P*n-Q))+n) == P*((n*Q)//(P*n-Q))*n: ans_list.append((n, (n*Q)//(P*n-Q))) for k in range(2, 10**7): n_ = n*k if (P*n_-Q) != 0 and (n_*Q)%(P*n_-Q) == 0 and (n_*Q)//(P*n_-Q) > 0: if Q*(((n_*Q)//(P*n_-Q))+n_) == P*((n_*Q)//(P*n_-Q))*n_: ans_list.append((n_, (n_*Q)//(P*n_-Q))) print(len(ans_list)) for n, m in ans_list: print(n, m)