import sys, time, random from collections import deque, Counter, defaultdict input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 for _ in range(ii()): d, k = mi() X = [] for x in range(-d - 1, d + 1): if abs(x) + abs((d - abs(x))) == d: X.append((x, (d - abs(x)))) X.append((x, -(d - abs(x)))) X = list(set(X)) X.sort(key = lambda x: x[0] ** 2 + x[1] ** 2) if len(X) < k: print('No') else: print('Yes') print(*X[k-1])