import sys input = sys.stdin.readline Q = int(input()) for _ in range(Q): L = [] D, K = map(int, input().split()) for x in range(1, D): y = D - x L.append((x**2 + y**2, x, y)) L.append((x**2 + y**2, -x, y)) L.append((x**2 + y**2, x, -y)) L.append((x**2 + y**2, -x, -y)) if D: L.append((D**2, D, 0)) L.append((D**2, -D, 0)) L.append((D**2, 0, D)) L.append((D**2, 0, -D)) else: L.append((0, 0, 0)) L.sort() if K > len(L): print("No") else: print("Yes") print(L[K-1][1], L[K-1][2])