#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T& x, const T& y){return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T& x, const T& y){return (x>y)?(x=y,true):false;};
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main(){
    int q; cin >> q;
    int d, k;
    REP(_,q){
        cin >> d >> k;
        vector<pair<int,P>> p;
        for(int x=-d;x<=d;x++)for(int y=-d;y<=d;y++){
            if(abs(x)+abs(y)==d){
                p.push_back({x*x+y*y,{x,y}});
            }
        }
        sort(ALL(p));
        int n=p.size();
        if(n<k)
            cout << "No" << endl;
        else{
            cout << "Yes" << endl;
            cout << p[k-1].second.first << " " << p[k-1].second.second << endl;
        }
    }
    return 0;
}