import sys input = sys.stdin.readline P,Q=map(int,input().split()) LIST=[] for i in range(1,2*10**5): if Q*2%i==0: LIST.append(i) LIST.append(Q*2//i) if P*2%i==0: LIST.append(i) LIST.append(P*2//i) ANS=[] if P%Q==0 and P//Q==1: ANS.append((2,2)) if P%Q==0 and P//Q==2: ANS.append((1,1)) for x in LIST: if Q-x*P!=0 and x*Q%(Q-x*P)==0: y=-x*Q//(Q-x*P) if x>0 and y>0: ANS.append((x,y)) ANS=sorted(set(ANS)) print(len(ANS)) for x,y in ANS: print(x,y)