import math

def solve(row):
    k = 2 * h - row[2]
    i,j = row[0],row[1]
    g = math.gcd(math.gcd(i,j),k)
    return [int(i/g),int(j/g),int(k/g)]

n,h = map(int,input().split())
res = []
for _ in range(n):
    row = list(map(int,input().split()))
    res.append(solve(row))
for x in res:
    print(" ".join(map(str,x)))

这道题把输入的点,关于z=h作对称,对应的纵坐标是 2h - z.