#include int main() { using namespace std; cin.tie(nullptr)->sync_with_stdio(false); int tt; cin >> tt; while (tt--) { int n, target; cin >> n >> target; if (~target & 1) { cout << "Yes\n"; for (int i = 1; i < n; ++i) for (int j = i + 1; j <= n; ++j) cout << i << ' ' << j << ' ' << (i == 1 ? target / 2 : 0) << '\n'; } else if (target % n == 0) { cout << "Yes\n"; for (int i = 1; i < n; ++i) for (int j = i + 1; j <= n; ++j) cout << i << ' ' << j << ' ' << target / n << '\n'; } else if (n == 3) { cout << "Yes\n"; for (int i = 1; i < n; ++i) for (int j = i + 1; j <= n; ++j) cout << i << ' ' << j << ' ' << (i == 1 and j == 2 ? target : 0) << '\n'; } else { cout << "No\n"; } } }