The Nagging React Newbie

 The Nagging React Newbie -- Juspay Hiring Solutions 





N=int(input())
strail={}
def sol(u,v):
    strail[u].append(v)
for i in range(N):
    n1=int(input())
    strail[n1]=[]
    
zero=int(input()) 
for i in range(zero):
    u,v=map(int,input().split())
    sol(u,v)
start=int(input())
end=int(input())
trail=[]
trail.append(start)
def trailaverse(strail,start):
    for i in strail[start]:
        if(i==end):
            return
        if(len(strail[start])==0):
            return
        else:
            trail.append(i)
            trailaverse(strail,i)
            
trailaverse(strail,start)
trail=sorted(trail)
for i in trail:
    print(i,end=" ")

Comments