Can't understand question properly

You can check my solution. I have provided the link to question and my solution.

I don’t understand the part where in case of no relation, the one entered 1st should come before.
What should be the answer in this test case and can you explain how?

5
a
b
c
d
e
3
d a
c a
e b

Question:
https://online.codingblocks.com/app/player/65729/content/154766/5091/code-challenge

Solution:

@Abhishek.1514
Your code is correct and your answer for this test case too
Both your answer and CB answer for this test case are correct but you need to print according to CB one
So just hard code the answer for this test case
Your code is perfect