#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool f(string a,string b)
{
	for(int i=0;i<a.size();i++)if(a[i]=='?')a[i]='a';
	return a<=b;
}
bool ff(string a,string b)
{
	for(int i=0;i<a.size();i++)if(a[i]=='?')a[i]='z';
	return b<=a;
}
int main()
{
	int n;cin>>n;int countl=0,countf=0;
	string a[10000],t;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>t;
	for(int i=0;i<n;i++)
	{
		countl+=f(a[i],t);
		countf+=ff(a[i],t);
	}
	for(int i=0;i<=countl-n+countf;i++)
	{
		cout<<(i?" ":"")<<n-countf+i+1;
	}
	cout<<endl;
}
