#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef pair P; typedef long double ld; template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} void solve(){ int d, k; cin >> d >> k; if(d == 0){ if(k == 1) cout << "Yes\n0 0\n"; else cout << "No\n"; return; } if(k > 4 * d){ cout << "No\n"; return; } vector> a; rep(x, d){ int y = d - x; a.emplace_back(x * x + y * y, x, y); } for(int y = 0; y > -d; y--){ int x = d + y; a.emplace_back(x * x + y * y, x, y); } for(int x = 0; x > -d; x--){ int y = -d - x; a.emplace_back(x * x + y * y, x, y); } rep(y, d){ int x = -d + y; a.emplace_back(x * x + y * y, x, y); } sort(a.begin(), a.end()); /* for(auto [tmp, x, y] : a){ cout << x << ' ' << y << "\n"; } */ auto [tmp, x, y] = a[k - 1]; cout << "Yes\n"; cout << x << ' ' << y << "\n"; } int main(){ int t; cin >> t; rep(_, t) solve(); return 0; }