import Control.Monad
f c = map (\x -> if x == '?' then c else x)
g t s
  | x /= y || x == EQ || y == EQ = (0,1)
  | x == LT = (0,0)
  | x == GT = (1,0)
  where
    x = t `compare` f 'a' s
    y = t `compare` f 'z' s
h (a,b) (c,d) = (a+c,b+d)
main = do
  n <- readLn
  ss <- replicateM n getLine
  t <- getLine
  let (x,y) = foldl1 h $ map (g t) ss
  putStrLn $ unwords $ map show [x+1..x+y+1]