local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
local str2tbl = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
local function tuplecmp(x, y)
    local i = 1
    while true do
        if x[i] == nil and y[i] ~= nil then return true end
        if y[i] == nil and x[i] ~= nil then return false end
        if x[i] == nil and y[i] == nil then return false end -- Don't care => false
        if x[i] ~= y[i] then return x[i] < y[i] end
        i = i + 1
    end
end
local N = read.nl()
local R = {}
for i=1,N do
    local s, p = read.l():split()
    table.insert(R, {s, -1 * tonumber(p), i})
end
table.sort(R, tuplecmp)
for _,v in ipairs(R) do
    local c,pp,i = table.unpack(v)
    print(i)
end
