from operator import itemgetter Q=int(input()) for tests in range(Q): D,K=map(int,input().split()) LIST=set() for i in range(-D,D+1): y=D-abs(i) LIST.add((i,y,i*i+y*y)) LIST.add((i,-y,i*i+y*y)) LIST=sorted(LIST,key=itemgetter(2)) if K-1>=len(LIST): print("No") else: print("Yes") print(*LIST[K-1][:2])