#include <iostream>
#include <cstring>

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 10004
int N;
string handles[MAXN];

string replace(string S, char c) {
   REP(i, SZ(S))
      if (S[i] == '?')
         S[i] = c;
   return S;
}


int compare(const string& a, const string b) {
   string aa = replace(a, 'a');
   string az = replace(a, 'z');
   string ba = replace(b, 'a');
   string bz = replace(b, 'z');

   if (az < ba) return -1;
   if (bz < aa) return +1;
   
   return 0;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);

   cin >> N;
   REP(i, N)
      cin >> handles[i];

   string T;
   cin >> T;

   int L = 1, R = N+1;
   REP(i, N) {
      int cmp = compare(T, handles[i]);
   // cerr << i << ": " << cmp << endl;
      if (cmp < 0)
         --R;
      else if (cmp > 0)
         ++L;
   }
   //cerr << L << ' ' << R << endl;

   FOR(i, L, R) {
      if (i > L) cout << ' ';
      cout << i;
   }
   cout << endl;

   return 0;
}
