#include <bits/stdc++.h>
using namespace std;
int n; string sa[10009], sz[10009], x;
int main() {
cin >> n;
for(int i = 0; i < n; i++) {
cin >> x;
for(int j = 0; j < x.size(); j++) {
sa[i] += (x[j] != '?' ? x[j] : 'a');
sz[i] += (x[j] != '?' ? x[j] : 'z');
}
}
cin >> x;
int l = 0, r = 0;
for(int i = 0; i < n; i++) {
if(x > sz[i]) l++;
else if(x >= sa[i]) r++;
}
//cout << l << ' ' << r << endl;
for(int i = l; i <= l + r; i++) {
if(i != l) cout << ' ';
cout << i + 1;
}
cout << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBuOyBzdHJpbmcgc2FbMTAwMDldLCBzelsxMDAwOV0sIHg7CmludCBtYWluKCkgewoJY2luID4+IG47Cglmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CgkJY2luID4+IHg7CgkJZm9yKGludCBqID0gMDsgaiA8IHguc2l6ZSgpOyBqKyspIHsKCQkJc2FbaV0gKz0gKHhbal0gIT0gJz8nID8geFtqXSA6ICdhJyk7CgkJCXN6W2ldICs9ICh4W2pdICE9ICc/JyA/IHhbal0gOiAneicpOwoJCX0KCX0KCWNpbiA+PiB4OwoJaW50IGwgPSAwLCByID0gMDsKCWZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKCQlpZih4ID4gc3pbaV0pIGwrKzsKCQllbHNlIGlmKHggPj0gc2FbaV0pIHIrKzsKCX0KCS8vY291dCA8PCBsIDw8ICcgJyA8PCByIDw8IGVuZGw7Cglmb3IoaW50IGkgPSBsOyBpIDw9IGwgKyByOyBpKyspIHsKCQlpZihpICE9IGwpIGNvdXQgPDwgJyAnOwoJCWNvdXQgPDwgaSArIDE7Cgl9Cgljb3V0IDw8IGVuZGw7CglyZXR1cm4gMDsKfQ==