integer N
character(10),allocatable,dimension(:)::S
integer,allocatable,dimension(:)::B
integer,allocatable,dimension(:)::num
integer tmpnum
character(10) tmp
read*,N
allocate(S(N),B(N),num(N))
do i=1,N
  read*,S(i),B(i)
  num(i)=i
end do
do i = 2,N
  do j = i, 2, -1 
    if (s(j) > s(j - 1)) exit
    if (s(j) < s(j - 1) )then
      tmp = s(j)
      s(j) = s(j - 1)
      s(j - 1) = tmp
      
      tmpnum = b(j)
      b(j)= b(j-1)
      b(j-1)= tmpnum
      
      tmpnum = num(j)
      num(j)= num(j-1)
      num(j-1)= tmpnum
    else
      if(b(j) > b(j-1) )then
            tmpnum = b(j)
      b(j)= b(j-1)
      b(j-1)= tmpnum
      
      tmpnum = num(j)
      num(j)= num(j-1)
      num(j-1)= tmpnum
      endif
    endif
  end do
end do

do i=1,N
  print"(I0)",num(i)
end do
end