from bisect import bisect_left

Q = int(input())
query = [list(map(int, input().split())) for _ in range(Q)]

def distance(x1, y1, x2, y2):
    return (x2-x1)**2 + (y2-y1)**2

for D, K in query:
    A = []
    for i in range(-D, D+1):
        if i == -D or i == D:
            A.append((0, i))
        else:
            A.append((-(D-abs(i)), i))
            A.append((D-abs(i), i))
    for i in range(len(A)):
        x, y = A[i]
        A[i] = (x, y, distance(0, 0, x, y))
    A.sort(key=lambda x:x[2])
    if K <= len(A):
        print("Yes")
        print(A[K-1][0], A[K-1][1])
    else:
        print("No")