d=[[36,-1],[12,-1],[24,-1],[12,-1],[44,-1],[27,-1],[10,-1],[50,-1],[16,-1],[1,-1]] head=0 for i in range(1,len(d)): if d[i][0]<=d[head][0]: __________ head=i else: p=head q=head while d[i][0]>d[p][0] and p!=-1: q=p __________ d[i][1]=p __________ p=head while __________: print(d[p][0],end=" ") p=d[p][1]