Problem:
Max Score: 250 Points

Problem Statement

Mr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N.

But he couldn't see some parts of the list. Invisible part is denoted ?.

Please calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and T) in lexicographical order.

Note: If there are pair of people with same handle name, either one may come first.

Input

The input is given from standard input in the following format.

N
S_1
S_2
:
S_N
T

Output

Calculate the possible index and print in sorted order. The output should be separated with a space. Don't print a space after last number.

Put a line break in the end.

Constraints

1 ≤ N ≤ 10000

1 ≤ |S_i|, |T| ≤ 20 (|A| is the length of A.)

S_i consists from lower-case alphabet and ?.

T consists from lower-case alphabet.

Scoring

Subtask 1 [ 130 points ]

There are no ?'s.

Subtask 2 [ 120 points ]

There are no additional constraints.

Sample Input 1

2
tourist
petr
e

Sample Output 1

1

There are no invisible part, so there are only one possibility.
The sorted handle names are e, petr, tourist, so e comes first.

Sample Input 2

2
?o?r?s?
?et?
e

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<string> v;

int main(){
    ll T; cin >> T;
    string store;
    for(ll i = 1; i <= T+1; i++){
        string x; cin >> x;
        v.push_back(x);
        if(i == T+1) store = x;
    }
    ll lastnum = T+1;
    ll firstnum = 1;
    set<ll> s;
    for(ll i = 0; i < v.size()-1; i++){
        string test = v[i];
        ll siz = min(store.size(), test.size());
        for(ll j = 0; j < siz; j++){
            if(test[j] == '?' && store[j] != 'a' && store[j] != 'z') break;
            else if(test[j] > store[j] && test[j] != '?'){
                s.insert(lastnum);
                lastnum --;
                break;
            }
            else if(test[j] < store[j] && test[j] != '?'){
                s.insert(firstnum);
                firstnum ++;
                break;
            }
            if(j == siz - 1){
                if(test.size() > store.size()){
                    s.insert(lastnum);
                    lastnum--;
                }
                else if(test.size() < store.size()){
                    s.insert(firstnum);
                    firstnum++;
                }
            }
        }
    }
    vector<ll> v2;
    for(ll i = 1; i <= T+1; i++){
        set<ll> :: iterator it = s.lower_bound(i);
        ll numfound = *it;
        if(numfound != i){
            v2.push_back(i);
        }
    }
    for(ll i = 0; i < v2.size(); i++){
        cout << v2[i];
        if(i != v2.size() - 1) cout << " ";
    }
    cout << endl;
}