for _ in range(int(input())): d,k = map(int,input().split()) if d == 0 and k == 1: print('Yes') print(0,0) continue z = d * 4 if k > z: print('No') else: print('Yes') ans = [] x,y = 0,d for i in range(d//2+1): for j in range(4): ans.append((x,y)) x += 1 y -= 1 ans.reverse() print(*ans[k-1])