import math A,B=map(int,input().split()) def solve(A,B): L=A*A+B*B if A=2: retu=solve(A//g,B//g) le=len(retu) retu0=retu[:le//2] retu1=retu[le//2:] retu=[] a,b=A//g,B//g l=a*a+b*b for x,y in retu0+retu1: for i in range(g): for j in range(g): retu.append(((x*g+i*l*g)%L,(y*g+j*l*g)%L)) else: retu=[] for x in range(L): retu.append((x*B%L,x*A%L)) for x in range(L): retu.append(((x*B+A)%L,(x*A+A-B)%L)) return retu ans_lst=solve(A,B) for x,y in ans_lst: print(x,y)