#include #include #include #include using namespace std; using i64 = long long; using P = pair; #define yn(pope) (pope ? "Yes" : "No") #define rep(i, n, m) for (int i = (n); i < (m); i++) #define rrep(i, n, m) for (int i = (n); i > m; i--) #define IINF (1 << 30) #define INF (1ll << 60) #define all(v) v.begin(), v.end() int main() { int Q; cin >> Q; auto f = [](P a, P b) -> bool { int a_ = a.first * a.first + a.second * a.second; int b_ = b.first * b.first + b.second * b.second; return a_ < b_; }; while (Q--) { int d, k; cin >> d >> k; vector

G; rep(i, 0, d + 1) { G.push_back({i, d - i}); G.push_back({-i, d - i}); G.push_back({i, i - d}); G.push_back({-i, i - d}); } sort(all(G)); G.erase(unique(all(G)), G.end()); sort(all(G), f); if (G.size() < k) { cout << "No" << endl; } else { k--; cout << "Yes" << endl; cout << G[k].first << " " << G[k].second << endl; } } return 0; }