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