#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int q; cin >> q; for (; q--;) { int d, k; cin >> d >> k; if (d == 0) { if (k == 1) { cout << "Yes\n"; cout << "0 0\n"; } else { cout << "No\n"; } } if (k > 4 * d) { cout << "No\n"; continue; } vector> points; for (int x = -d; x <= d; x++) { points.push_back({x, d - abs(x)}); if (x != d && x != -d) { points.push_back({x, abs(x) - d}); } } sort(points.begin(), points.end(), [](const pair &a, const pair &b) { return a.first * a.first + a.second * a.second < b.first * b.first + b.second * b.second; }); cout << "Yes\n"; cout << points[k - 1].first << " " << points[k - 1].second << "\n"; } }