Prolog Query works for simple example