print("Enter the number of tuplkes")
t=int((input())
mylist=[]
for i in range(0,t):
    print "enter the elements of tuple no.", i
    mylist.append((int(x) for x in raw_input().split()))
    
list1 =sorted(mylist key=itemgetter[-1])
print(list1)