I want to get all planets and its moons O that are further away than planet P
% planets
orbits(mercury, sun).
orbits(venus, sun).
orbits(earth, sun).
orbits(mars, sun).
orbits(jupiter, sun).
orbits(saturn, sun).
orbits(uranus, sun).
orbits(neptune, sun).
ae(mercury, 0.39).
ae(venus, 0.72).
ae(earth, 1).
ae(mars, 1.52).
ae(jupiter, 5.20).
ae(saturn, 9.54).
ae(uranus, 19.22).
ae(neptune, 30.06).
% moons
orbits(moon, earth).
orbits(deimos, mars).
orbits(phobos, mars).
orbits(ganymede, jupiter).
orbits(callisto, jupiter).
orbits(io, jupiter).
orbits(europa, jupiter).
orbits(titan, saturn).
orbits(enceladus, saturn).
orbits(titania, uranus).
orbits(oberon, uranus).
orbits(umbriel, uranus).
orbits(ariel, uranus).
orbits(miranda, uranus).
orbits(triton, neptune).
First I tried to get all planets that are further away than P
outer_orbit(P,O):-ae(O,X),ae(P,Y),X>Y.
Now I need to print all Moons that are in O
How can I do that?