#include using namespace std; int main() { int Q; cin >> Q; while (Q--) { int N,T; cin >> N >> T; if(T%2 != 0 && T%N != 0) { cout << "No" << endl; } else if(T%N == 0) { cout << "Yes" << endl; for(int i = 1; i <= N; i++) { for(int j = i+1; j <= N; j++) { cout << i << " " << j << " " << T/N << endl; } } } else { cout << "Yes" << endl; for(int i = 1; i <= N; i++) { for(int j = i+1; j <= N; j++) { if(i == 1) { cout << i << " " << j << " " << T/2 << endl; } else { cout << i << " " << j << " " << 0 << endl; } } } } } }