Problem code vivek and party

getting wrong ans using topological sort,tell me what logic should i apply

its topological sorting only… you are getting wrong answer because if we don’t have any relation between two nodes than the one which come 1st in the input should be printed 1st.