import bisect Q = int(input()) for _ in range(Q): d,k = map(int,input().split()) A = [] P = [] for y in range(-100,101,1): for x in range(-100,101,1): if abs(y) + abs(x) == d: e = pow(x*x + y*y, 0.5) A.append(e) P.append((y,x)) A.sort() ans = "No" for y,x in P: e = pow(x*x + y*y, 0.5) L = bisect.bisect_left(A, e) R = bisect.bisect_right(A, e) if L < k and k <= R: ans = "Yes" c = [y,x] break print(ans) if ans == "Yes": print(*c)