#include<iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int N,A=0,Z=0;
string str[10000],a[10000],z[10000],T;
int main(){
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>str[i];
		a[i]=str[i];
		z[i]=str[i];
		for(int j=0;j<str[i].size();++j){
			if(str[i][j]=='?'){
				a[i][j]='a';
				z[i][j]='z';
			}
		}
	}
	cin>>T;
	for(int i=0;i<N;++i){
		if(T>a[i]&&T>z[i])++A;
		if(T<a[i]&&T<z[i])++Z;
	}
	for(int i=A+1;i<=N-Z;++i){
		cout<<i<<" ";
	}
	cout<<N-Z+1<<endl;
	return 0;
}
