#include //#include using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int Q, x; cin >> Q; vector>> w(101); for (int i=-100; i<=100; i++){ for (int j=-100; j<=100; j++){ x = abs(i)+abs(j); if (x<=100){ w[x].push_back({i*i+j*j, i, j}); } } } for (int i=0; i<=100; i++) sort(w[i].begin(), w[i].end()); while(Q--){ int D, K; cin >> D >> K; if (w[D].size() >= K){ cout << "Yes" << endl; cout << get<1>(w[D][K-1]) << " " << get<2>(w[D][K-1]) << endl; } else{ cout << "No" << endl; } } return 0; }