Q = int(input()) za1 = [] za2 = [] for i in range(-100,101): for j in range(-100,101): ma = abs(i)+abs(j) yu = i**2 + j**2 za1.append([ma,yu,i,j]) za1.sort() #print(za1[:20]) for i in range(Q): D,K = map(int,input().split()) if za1[0][0] == D: if za1[0+K-1][0] == D: print("Yes") print(*[za1[0+K-1][2],za1[0+K-1][3]]) else: print("No") else: if za1[-1][0] < D: print("No") else: ng,ok = 0,len(za1)-1 while abs(ok-ng)>1: mid = abs((ok+ng)//2) if za1[mid][0] < D: ng = mid else: ok = mid if za1[ok+K-1][0] == D: print("Yes") print(*[za1[ok+K-1][2],za1[ok+K-1][3]]) else: print("No")