#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, f = 0, b = 0;
	cin >> n;
	string s;
	vector<bool> sb(n, false);
	vector<string> ss,sa,sz;
	rep(i, n) {
		cin >> s;
		ss.push_back(s);
	}
	rep(i, n) {
		string a, z;
		rep(j, ss[i].size()) {
			if (ss[i][j] == '?') {
				a.push_back('a');
				z.push_back('z');
			}
			else {
				a.push_back(ss[i][j]);
				z.push_back(ss[i][j]);
			}
		}
		sa.push_back(a);
		sz.push_back(z);
	}
	cin >> s;
	rep(i, n) {
		//cout << sa[i] << " " << sz[i] << endl;
		if (sa[i] > s) {
			b++;
		}
		else if (sz[i] < s) {
			f++;
		}
	}
	vi v;
	range(i,1 + f, n + 2 - b) {
		v.push_back(i);
	}
	cout << v << endl;
}
