#include using namespace std; using ll = long long; #define rep(i, n) for(int i = 0; i < n; i++) int main() { int Q; cin >> Q; using P = pair; using PP = pair; rep(i, Q) { int d, k; cin >> d >> k; vector v; for(ll x = -d; x <= d; x++ ) { ll y = d - abs(x); if(y) { P p; p.first = x; p.second = y; ll ud = x * x + y * y; v.push_back(PP(ud, p)); p.second = -y; v.push_back(PP(ud, p)); } else { P p; p.first = x; p.second = 0; ll ud = x * x; v.push_back(PP(ud, p)); } } if((int)v.size() < k) cout << "No" << endl; else { sort(v.begin(), v.end()); cout << "Yes" << endl; k--; ll x = v[k].second.first; ll y = v[k].second.second; cout << x << " " << y << endl; } } }