from bisect import*

n,*s,t=open(0)

print((*list(range(bisect_left(sorted(u.replace(*'?z')for u in s),t)+1,bisect(sorted(u.replace(*'?a')for u in s),t)+2))))
from bisect import*

n,*s,t=open(0)

x,y=[sorted(u.replace('?',c)for u in s)for c in'za']

print((*list(range(bisect_left(x,t)+1,bisect(y,t)+2))))
from bisect import *

n, *s, t = open(0)
print(
    (
        *list(
            range(
                bisect_left(sorted(u.replace(*"?z") for u in s), t) + 1,
                bisect(sorted(u.replace(*"?a") for u in s), t) + 2,
            )
        )
    )
)

from bisect import *

n, *s, t = open(0)
x, y = [sorted(u.replace("?", c) for u in s) for c in "za"]
print((*list(range(bisect_left(x, t) + 1, bisect(y, t) + 2))))

-print( -    ( -        *list( -            range( -                bisect_left(sorted(u.replace(*"?z") for u in s), t) + 1, -                bisect(sorted(u.replace(*"?a") for u in s), t) + 2, -            ) -        ) -    ) -) +x, y = [sorted(u.replace("?", c) for u in s) for c in "za"] +print((*list(range(bisect_left(x, t) + 1, bisect(y, t) + 2))))