#include using namespace std; int main() { int Q; cin >> Q; while (Q--){ int D, K; cin >> D >> K; vector> d; for (int x = -D; x <= D; x++){ for (int y = -D; y <= D; y++){ if (abs(x) + abs(y) == D){ d.push_back(make_tuple(x * x + y * y, x, y)); } } } sort(d.begin(), d.end()); if ((int) d.size() < K){ cout << "No" << endl; } else { auto [_, x, y] = d[K - 1]; cout << "Yes" << endl; cout << x << ' ' << y << endl; } } }