import sys from collections import deque, Counter sys.setrecursionlimit(5 * 10 ** 5) from pypyjit import set_param set_param('max_unroll_recursion=-1') input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 from math import gcd p, q = mi() g = gcd(p, q) p //= g; q //= g ans = [] for n in range(1, 6 * 10 ** 7): if p * n - q > 0 and (q * n) % (p * n - q) == 0: m = (q * n) // (p * n - q) if m > 0: ans.append((n, m)) ans.append((m, n)) ans = list(set(ans)) ans.sort() print(len(ans)) for n, m in ans: print(n, m)