Vicky caught four animals in the Great Animal Forest and put them into four separate cages. The four animals are:
the lion, that always tells the truth;
the jackal, that always lies;
the parrot, that always repeats the last given answer (if he is the first one, he randomly says “yes” or “no”);
the giraffe, that is so slow that he always truthfully answers the previous question (if he is the first one, he also randomly says “yes” or “no”).
The other animals want to free them and send the small, smart hedgehog on the way to size up the situation. In the middle of the night, the hedgehog creeps into the camp of the Vicky and tries to figure out which animal sits in which cage. One by one, he asks them “are you the jackal?” After hearing the four answers, the hedgehog only knows in which cage the giraffe sits. Then the hedgehog asks them in the same order “are you the giraffe?” After hearing the four answers, the hedgehog also knows in which cage the jackal sits. Because the hedgehog then still does not know in which cages all animals sit, he asks the first animal “are you the parrot?” The answer is “yes”, and now the hedgehog knows exactly which animal sits in which cage. The hedgehog returns to the other animals and together they free the captured animals.
Which animal was in which cage?