#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int Q; cin >> Q; auto f = [&](pair x){ return x.first * x.first + x.second * x.second; }; while(Q--){ int D, K; cin >> D >> K; vector> p; p.reserve(4 * D); for(int i = 0; i <= D; i++){ p.emplace_back(i, D - i); p.emplace_back(i, -(D - i)); p.emplace_back(D - i, i); p.emplace_back(-(D - i), i); } sort(p.begin(), p.end()); p.erase(unique(p.begin(), p.end()), p.end()); sort(p.begin(), p.end(), [&](pair lhs, pair rhs){ return f(lhs) < f(rhs); }); K--; if(K >= p.size()){ cout << "No\n"; continue; } cout << "Yes\n" << p[K].first << ' ' << p[K].second << '\n'; } }