#include #include using namespace std; using namespace atcoder; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; //using mint = modint1000000007; //using mint = modint998244353; void solve(int N, int T){ if(T%N==0){ int a = T/N; cout << "Yes" << endl; rep(i,N){ REP(j,i+1,N){ cout << i+1 << " " << j+1 << " " << a << endl; } } return; } if(N > 2){ int x = 2; int y = N-2; int a = -1; int b = -1; rep(aa,101){ rep(bb,101){ if(x*aa + y*bb == T){ a = aa; b = bb; } } } if(a >= 0){ cout << "Yes" << endl; rep(i,N){ REP(j,i+1,N){ if(i==0) cout << i+1 << " " << j+1 << " " << a << endl; else cout << i+1 << " " << j+1 << " " << b << endl; } } return; } } cout << "No" << endl; } int main(){ int Q; cin >> Q; rep(q,Q){ int N, T; cin >> N >> T; solve(N, T); } return 0; }