nxt = [((0, 0, 0),)]
while nxt:
cur, nxt = nxt, []
for path in cur:
x, y, z = path[-1]
targets = [(a, b, c) for a, b, c in ((x + 3, y, z + 2),
(x, y + 3, z + 1),
(x + 1, y + 2, z))
if a * a + b * b + c * c < 125]
if targets:
for abc in targets:
nxt.append(path + (abc,))
else:
print(*[(u - a, v - b, w - c) for (a, b, c), (u, v, w)
in zip(path, path[1:])])