local n = io.read("*n", "*l")
local a, b = {}, {}
for i = 1, n do
  local s = io.read()
  a[i] = s:gsub("?", "a")
  b[i] = s:gsub("?", "z")
end
table.sort(a)
table.sort(b)
local t = io.read()
local min = n + 1
for i = n, 1, -1 do
  if b[i] < t then
    break
  else
    min = i
  end
end
local max = 1
for i = 1, n do
  if t < a[i] then
    break
  else
    max = i + 1
  end
end
for k = min, max do
  io.write(k)
  io.write(k == max and "\n" or " ")
end
