#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
long gcd3(long a, long b, long c) {
return gcd(gcd(abs(a), abs(b)), abs(c));
}
int main() {
int n;
long h;
cin >> n >> h;
while (n--) {
long x, y, z;
cin >> x >> y >> z;
long i = x;
long j = y;
long k = 2 * h - z;
long g = gcd3(i, j, k);
// 化简使得 gcd(i, j, k) = 1
i /= g;
j /= g;
k /= g;
cout << i << " " << j << " " << k << endl;
}
return 0;
}



京公网安备 11010502036488号