#include <bits/stdc++.h>
using namespace std;
int main(){
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++){
    int N, T;
    cin >> N >> T;
    if (N == 3){
      cout << "Yes" << endl;
      cout << 1 << ' ' << 2 << ' ' << 0 << endl;
      cout << 1 << ' ' << 3 << ' ' << 0 << endl;
      cout << 2 << ' ' << 3 << ' ' << T << endl;
    } else {
      int x = -1, y = -1;
      for (int j = 0; j <= T; j++){
        for (int k = -j; k <= T; k++){
          if (j * N + k * 2 == T){
            x = j;
            y = k;
          }
        }
      }
      if (x == -1 && y == -1){
        cout << "No" << endl;
      } else {
        cout << "Yes" << endl;
        for (int j = 0; j < N; j++){
          for (int k = j + 1; k < N; k++){
            int c;
            if (j == 0){
              c = x + y;
            } else {
              c = x;
            }
            cout << j + 1 << ' ' << k + 1 << ' ' << c << endl;
          }
        }
      }
    }
  }
}