The new Formula 1 season is about to begin and Chef has got the chance to work with the Formula 1 technical team.  
Recently, the pre-season testing ended and the technical team found out that their timing system for qualifying was a little bit buggy. So, they asked Chef to fix it before the season begins.  
His task is to write a program to find the starting lineup of the race by taking the timings of the drivers in qualifying.
(If you don’t know the rules that make the starting grid in Formula 1, consider that the driver with the least time will start at the front). 
Note: 
- Two or more drivers can have the same name.  
- Every driver will have a distinct time.  

-----Input:-----
- The first line of the input consists of a single integer $T$ denoting the number of test cases.  
- First line of each test case consists of a single integer $N$ denoting the number of drivers to set a time.  
- The following $2*N$ lines consists of the driver’s name $S$ in one line and its timing details  $X$ (in milliseconds) in the next line.  

-----Output:-----
- For each test case output the starting lineup of the race i.e., name of each driver in the order they will start the race. Print each name in a new line.  

-----Constraints-----
- 1 <= $T$ <= 10  
- 1 <= $N$ <= 105 
- 1 <= $|S|$ <= 20  
- 1 <= $X$ <= 109 

-----Subtasks-----
Subtask #1 (20 points): 
- 1 <= $N$ <= 100  
Subtask #2 (80 points): 
- Original Constraints  

-----Sample Input:-----
2

3

Hamilton

75000

Vettel

76000

Bottas

75500

2

Leclerc

666666

Verstappen

666777  

-----Sample Output:-----
Hamilton

Bottas

Vettel

Leclerc

Verstappen  

-----EXPLANATION:-----
The drivers with the least time are ahead in the lineup.

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
t=int(input())
for i in range(t):
 n=int(input())
 if n<101:
  l1=[]
  l2=[]
  d=dict()
  for i in range(1,2*n+1):
   if i%2==0:
    l1.append(int(input()))
   else:
    l2.append(str(input()))
  r1=[]
  for i in l1:
   r1.append(i)
  l1.sort()
  ind=[]
  for i in l1:
   a=r1.index(i)
   ind.append(a)
  for i in ind:
   print(l2[i])
 else:
  print(0)
  break
 


# cook your dish here
t=int(input())
for i in range(t):
 n=int(input())
 if n<101:
  l1=[]
  l2=[]
  d=dict()
  for i in range(1,2*n+1):
   if i%2==0:
    l1.append(int(input()))
   else:
    l2.append(str(input()))
  r1=[]
  for i in l1:
   r1.append(i)
  l1.sort()
  ind=[]
  for i in l1:
   a=r1.index(i)
   ind.append(a)
  for i in ind:
   print(l2[i])
 else:
  break
 


t=int(input())
op=""
for j in range(0,t):
 n=int(input())
 d=dict()
 for i in range(0,n):
  s=input()
  tp=int(input())
  d[tp]=s
 for k in sorted(d):
  print(d[k])
print(op)

t = int(input())
for _ in range(t):
 n = int(input())
 time = []
 l = dict()
 for __ in range(n):
  name = input()
  t = int(input())
  l[t] = name
  time.append(t)
 time.sort()
 for i in range(n):
  print(l[time[i]])

# cook your dish here
t=int(input())
for i in range(t):
 n=int(input())
 l1=[]
 l2=[]
 d=dict()
 for i in range(1,2*n+1):
  if i%2==0:
   l1.append(int(input()))
  else:
   l2.append(str(input()))
 r1=[]
 for i in l1:
  r1.append(i)
 l1.sort()
 ind=[]
 for i in l1:
  a=r1.index(i)
  ind.append(a)
 for i in ind:
  print(l2[i])
 


t = int(input())
for _ in range(t):
 n = int(input())
 l = 2*n
 l1 = []
 l2 = []
 for i in range(l):
  if i%2 == 0:
   s = input()
   #x = input()
   l1.append(s)
  else:
   s = int(input())
   l2.append(s)
 #print(l2)
 t1 = []
 t1 = sorted(l2)
 
 t2 = []
 #print(t1)
 for i in t1:
  #print(l2.index(i))
  t2.append(l1[l2.index(i)])
 for j in t2:    
  print(j)

# cook your dish here
tc = int(input())
for t in range(tc):
 n = int(input())
 tr=['']*n
 nr=['']*n
 ck=False
 for i in range(n):
  name = input()
  tim = int(input())
  if not ck:
   ck=True
   tr[0]=tim
   nr[0]=name
  else:
   tr[i]=tim
   nr[i]=name
   key=tr[i]
   kname=nr[i]
   k=i-1
   while k>=0 and tr[k]>key:
    tr[k+1]=tr[k]
    nr[k+1]=nr[k]
    k = k - 1
   tr[k+1]=key
   nr[k+1]=kname
 print(*nr,sep='\n')

# cook your dish here
tc = int(input())
for t in range(tc):
 n = int(input())
 tr=['']*n
 nr=['']*n
 ck=False
 for i in range(n):
  name = input()
  tim = int(input())
  if not ck:
   ck=True
   tr[0]=tim
   nr[0]=name
  else:
   tr[i]=tim
   nr[i]=name
   for j in range(i+1):
    key=tr[j]
    kname=nr[j]
    k=j-1
    while k>=0 and tr[k]>key:
     tr[k+1]=tr[k]
     nr[k+1]=nr[k]
     k = k - 1
    tr[k+1]=key
    nr[k+1]=kname
 print(*nr,sep='\n')

# cook your dish here
n=int(input())
for i in range(n):
 num=int(input())
 d={}
 for j in range(num):
  s=input()
  a=int(input())
  d[a]=s
 
 for j in sorted (d):
  print(d[j])

T=int(input())
while T:
 alist=[]
 N=int(input())
 for _ in range(N):
  S=input()
  X=int(input())
  alist.append(tuple([S,X]))
 alist=sorted(alist,key=lambda t1 :t1[1]) 
 for _ in alist:
  print(_[0])
 T-=1 

# cook your dish here
t=int(input())
name=list()
time=list()
ro=list()
for i in range(t):
 n=int(input())
 for j in range(n):
  name.append(input())
  time.append(int(input()))
 p=time.copy()
 time.sort()
 for x in range(len(time)):
  for y in range(len(p)):
   if time[x]==p[y]:
    ro.append(y)
 for m in ro:
  print(name[m])
 name.clear()
 time.clear()
 ro.clear()
 p.clear()

t=int(input())
for _ in range(t):
 n=int(input())
 arr=[]
 for i in range(n):
  pos=[]
  name=input()
  time=int(input())
  pos.append(time)
  pos.append(name)
  arr.append(pos)
 arr.sort()
 for i in range(n):
  print(arr[i][1])

# cook your dish here
t=int(input())
name=list()
time=list()
ro=list()
for i in range(t):
 n=int(input())
 for j in range(n):
  name.append(input())
  time.append(int(input()))
 p=time.copy()
 time.sort()
 for x in range(len(time)):
  for y in range(len(p)):
   if time[x]==p[y]:
    ro.append(y)
 for m in ro:
  print(name[m])
 name.clear()
 time.clear()
 ro.clear()

import operator
for _ in range(int(input())):
 n = int(input())
 d = dict()
 for i in range(n):
  value = input()
  key = int(input())
  d[key] = value
 for v in sorted(d):
  print(d[v])
 
   


import collections
for _ in range(int(input())):
 playerSize = int(input())
 player = []
 values = []
 newValues = []
 for i in range(playerSize):
  player.append(input())
  values.append(int(input()))
 newValues = sorted(values)
 #print(values)
 #print(player)
 #print(newValues)
 for i in range(playerSize):
  for j in range(playerSize):
   if newValues[i]==values[j]:
    print(player[j])

# cook your dish here
for _ in range(int(input())):
 d={}
 for __ in range(int(input())):
  name = str(input())
  time = int(input())
  d[time] = name
  d = dict(sorted(d.items()))
 for v in d.values():
  print(v) 

def asc_merge_sort(time,name):
 length=len(time)
 if length>1:
  # finding the middle point if the timeay
  if length%2==0:
   mid=length//2
  else:
   mid=length//2+1

  # for dividing the timeay into two sub parts
  l = time[:mid]
  r =time[mid:]
  ll = name[:mid]
  rr =name[mid:]

  # sorting the both sub timeays
  asc_merge_sort(l,ll)
  asc_merge_sort(r,rr)
  
  i=j=k=0
  while i<len(l) and j< len(r):
   if l[i]<r[j]:
    time[k]=l[i]
    name[k]=ll[i]
    i+=1
   else:
    time[k]=r[j]
    name[k]=rr[j]
    j+=1
   k+=1
  while i<len(l):
   time[k]=l[i]
   name[k]=ll[i]
   i+=1
   k+=1
  while j<len(r):
   time[k]=r[j]
   name[k]=rr[j]
   j+=1
   k+=1
 return name
for _ in range(int(input())):
 nm=[]
 tm=[]
 n=int(input())
 for i in range(n):
  nm.append(input())
  tm.append(int(input()))
 ot=asc_merge_sort(tm,nm)
 for k in ot:
  print(k)
  


for _ in range(int(input())):
 n=int(input())
 a=[]
 b=[]
 d=[]
 for i in range(n):
   a.append(input())
   b.append(int(input()))
   c=b
 c=sorted(c)
 for i in range(n):
  for j in range(n):
   if(c[i]==b[j]):
    d.append(a[j])
 for i in d:
  print(i)



for _ in range(int(input())):
 ranks = []
 lens = int(input())
 for i in range(lens):
  name = input()
  timing = int(input())
  ranks.append([name, timing])
 ranks = sorted(ranks, key = lambda x:x[1])
 for i in ranks:
  print(i[0])


try:
 for _ in range(int(input())):
  n=int(input())
  driver=[]
  for __ in range(n):
   name=input()
   time=int(input())
   driver.append((name,time))
  driver.sort(key=lambda x: x[1])
  for ele in driver:
   print(ele[0])
except:
 pass

try:
 for _ in range(int(input())):
  n=int(input())
  driver=[]
  for __ in range(n):
   name=input()
   time=int(input())
   driver.append((name,time))
  driver.sort(key=lambda x: x[1])
  for ele in driver:
   print(ele[0])
  
except:
 pass

# cook your dish here
def takeSecond(elem):
 return elem[1]

t = int(input())
for _ in range(t):
 # Input Section
 n = int(input())
 drivers_and_time = []
 for _ in range(n):
  driver = input()
  his_time = int(input())
  drivers_and_time.append((driver, his_time))
 # Logic and Output Section
 drivers_and_time.sort(key=takeSecond)
 for item in drivers_and_time:
  print(item[0])

# cook your dish here

t = int(input())
for rep in range(t):
 n = int(input())
 l = []
 for i in range(n):
  s = input()
  x = int(input())
  l.append([s,x])
 l.sort(key = lambda x: x[1])
 for j in l:
  print(j[0])

# cook your dish here
t=int(input())
for i in range(0,t):
 x=[]
 n=int(input())
 for j in range(0,n):
  name=str(input())
  time=int(input())
  s=(time,name)
  x.append(s)
 x=sorted(x,key=lambda x:(x[0],x[1])) 
 for j in range(0,len(x)):
  print(x[j][1])

# cook your dish here
T=int(input())
for _ in range(T):
 N=int(input())
 l=[]
 for i in range(N):
  name=input()
  time=int(input())
  l.append((name,time))
 l=sorted(l,key=lambda ele:ele[1])
 for j in range(N):
  print(l[j][0])