import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd q = int(input()) dk = [list(map(int,input().split())) for i in range(q)] def eu(x,y): return x**2 + y**2 for d,k in dk: pos = [] if d == 0: if k == 1: print('Yes') print(0,0) else: print('No') continue for x in range(d+1): y = d-abs(x) pos.append([eu(x,y),x*1000+y]) pos.append([eu(x,y),x*1000+y]) if x != 0 and y != 0: pos.append([eu(x,y),x*1000+y]) pos.append([eu(x,y),x*1000+y]) pos.sort() if len(pos) >= k >= 1: ans = pos[k-1][1] print('Yes') print(ans//1000, ans%1000) else: print('No')