import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

/// t より前にくる文字列がいくつあるか
int countLessOrEqual(string t, string[] ss) {
    return cast(int) ss.map!(e => e.replace("?", "a")).count!(e => e <= t);
}

/// t より後ろにくる文字列がいくつあるか
int countGreaterOrEqual(string t, string[] ss) {
    return cast(int) ss.map!(e => e.replace("?", "z")).count!(e => e >= t);
}

void calc(string t, string[] ss) {
    int n = cast(int) ss.length;

    int a = countGreaterOrEqual(t, ss);
    int high = n - a + 1;

    int b = countLessOrEqual(t, ss);
    int low = b + 1;

    auto ans = iota(high, low + 1).map!(e => e.to!string).join(" ");
    writeln(ans);
}

void main() {
    int n = readint;
    string[] ss;
    for (int i = 0; i < n; i++) ss ~= read!string;
    string t = read!string;
    calc(t, ss);
}
