#include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; typedef long long ll; #define rep(i,n) for (int i = 0; i < int(n);i++) void solve(){ int d,k; cin >> d >> k; vector>> a; for (int x = -d; x <= d;x++){ for (int y = -d; y <= d;y++){ if (abs(x)+abs(y) == d){ a.push_back({x*x+y*y,{x,y}}); } } } sort(a.begin(),a.end()); //cout << "size:" << a.size() << endl; if (k <= a.size()){ cout << "Yes\n"; cout << a[k-1].second.first << " " << a[k-1].second.second << endl; } else cout << "No\n"; return; } int main(){ int q; cin >> q; while(q--){ solve(); } return 0; }