from collections import defaultdict import bisect # ダブリング dp[i][j]:=jから2**i回遷移したときの到達点 # https://atcoder.jp/contests/abc167/submissions/40815296 # N,K=map(int,input().split()) # A=list(map(int,input().split())) # dp=[[-1]*N for _ in range(60)] # for j in range(N): # dp[0][j]=A[j]-1 # for i in range(1,60): # for j in range(N): # dp[i][j]=dp[i-1][dp[i-1][j]] # i=0 # now=0 # while(K>0): # if (K&1)==1: # now=dp[i][now] # i+=1 # K>>=1 # print(now+1) dxdy1 = ((0, 1), (0, -1), (1, 0), (-1, 0)) dxdy2 = ((0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (-1, -1), (1, -1), (-1, 1)) dxdy3 = ((0, 1), (1, 0)) dxdy4 = ((1, 1), (1, -1), (-1, 1), (-1, -1)) INF = float("inf") MOD = 998244353 mod = 998244353 # memo : len([a,b,...,z])==26 Q = int(input()) def count_lattice_points_in_circle(r, K): count = 0 c2 = 0 rr = int(r**0.5) for x in range(-K, K + 1): for y in range(-K, K + 1): if x + y != K: continue return count, c2 for i in range(Q): D, K = map(int, input().split()) ok = False kouho = defaultdict(int) dist = [] view = defaultdict(int) for x in range(D + 1): y = D - x for dx, dy in ((1, 1), (-1, 1), (1, -1), (-1, -1)): nx = x * dx ny = y * dy if view[nx, ny] != 0: continue view[nx, ny] = 1 kouho[nx, ny] = x**2 + y**2 dist.append(x**2 + y**2) dist.sort() for key, val in kouho.items(): point = bisect.bisect_left(dist, val) p2 = bisect.bisect_left(dist, val + 1) # print(i, key, point, p2) if point < K and p2 >= K: print("Yes") print(*key) ok = True break if not ok: print("No")