import java.util.*;
import java.math.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
int n=sc.nextInt();
long h=sc.nextLong();
for(int i=0;i<n;i++){
long x1=sc.nextLong();
long y1=sc.nextLong();
long z1=sc.nextLong();
z1=h+h-z1;
BigInteger x=BigInteger.valueOf(x1);
BigInteger y=BigInteger.valueOf(y1);
BigInteger z=BigInteger.valueOf(z1);
BigInteger jg=x.gcd(y.gcd(z));
System.out.printf("%d %d %d\n",x.divide(jg),y.divide(jg),z.divide(jg));
}
}
}